/*获取订单号*/
var orderId = sessionStorage.getItem("orderId");
var parentOrderId = sessionStorage.getItem("parentOrderId");
var ordersts = ""
var ordertype = ""
var warehouses = ""
var wuliu = "";
var result11 = {}
getAllWare()
var fahuo = "";
var arrs = [];
var orderSplitStatus = "";
var expressNums = ""; //物流单号
var redReal = "";
var pushOrdererrorCode = 1;
var custormerCode = "";

var deliverTypeArr = { '10': '快递', '20': '快运-送货上门', '21': '快运-站点自提', '30': '专车包车', '40': '鑫方盛物流', '50': '上门自提', '53': '无人仓自提' };
var linkage = false //订单类别,发货仓,订单类型,配送方式
var linkagenum = 0

function renderNewCustomerNameInput() {

}

function getAllWare() { //获取所有发货仓
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.publics.queryWarehouseInfo,
        cache: false, //禁用缓存
        type: "POST",
        dataType: "json",
        async: false, //优先运行
        data: JSON.stringify({
            warehouseCode: ""

        }),
        success: function(data) {
            warehouses = data;
            sessionStorage.setItem("warehouses", JSON.stringify(data))
        },
    })
}

getOrderDetail();
/*通过订单号获取订单详情*/
// 如果是 山西路桥竞价订单 显示 ‘渠道商品信息’
var channelPrduct = '';

function getOrderDetail() {

    $.ajax({
        type: "POST",
        /*root.orderInter.order_queryOrderDetails*/
        url: root.dockingplatform.queryPreOrderDetail,
        cache: false, //禁用缓存
        dataType: "json",
        async: false,
        data: {
            "orderId": orderId, // 订单编号
        },
        success: function(results) {
            QueryorderDetail(results);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest);
        }
    });
}


/*转换状态函数*/
function changeOrderState(orderState) {
    switch (orderState) {
        /*订单状态*/
        case 9:
            return "待付款";
            break;
        case 10:
            return "待付款";
            break;
        case 20:
            return "待审核";
            break;
        case 30:
            return "待配货";
            break;
        case 40:
            return "待出库";
            break;
        case 50:
            return "待发货";
            break;
        case 60:
            return "待收货";
            break;
        case 70:
            return "已收货，待结算";
            break;
        case 80:
            return "订单成功";
            break;
        case 90:
            return "交易完成";
            break;
        case 100:
            return "已取消";
            break;
        case 110:
            return "交易关闭";
            break;
        case 120:
            return "临采商品订单";
            break;
        case 130:
            return "危险品订单";
            break;
        case 140:
            return "经纬度异常";
            break;
    }
}

function calculate(listAddressReceiver, type) {
    var math = ""
    var phone = ""
    var he = ""
    var size = listAddressReceiver.length
    if (listAddressReceiver.length == 0) {
        return "";
    }
    for (i = 0; i < size; i++) {
        if (i < size - 1) {
            math += listAddressReceiver[i].receiver_name + " ;"
            phone += listAddressReceiver[i].mobile + " ; "
            if (i % 2 != 0) {
                he += listAddressReceiver[i].receiver_name + listAddressReceiver[i].mobile + " ; <br/> "
            } else {
                he += listAddressReceiver[i].receiver_name + listAddressReceiver[i].mobile + " ;  "
            }
        } else {
            math += listAddressReceiver[i].receiver_name
            phone += listAddressReceiver[i].mobile
            if (i % 2 != 0) {
                he += listAddressReceiver[i].receiver_name + listAddressReceiver[i].mobile + "  <br/> "
            } else {
                he += listAddressReceiver[i].receiver_name + listAddressReceiver[i].mobile + "   "
            }
        }
    }
    if (type == 1) {
        return math
    } else if (type == 2) {
        return phone
    } else if (type == 3) {
        return he
    }
}

function changePayTypeState(payTypeState) {
    switch (payTypeState) {
        /*支付方式*/
        case 1001:
            return "在线支付";
            break;
        case 1002:
            return "支付宝支付";
            break;
        case 1003:
            return "微信支付";
            break;
        case 1101:
            return "货到付款";
            break;
        case 1102:
            return "货到付款-现金";
            break;
        case 1103:
            return "货到付款-pos机";
            break;
        case 1201:
            return "账期支付";
            break;
        case 1301:
            return "银行转账";
            break;
        case 1401:
            return "银行汇票";
            break;
    }
}


function changeDeliveryMethodType(DeliveryMethodType) {
    switch (DeliveryMethodType) {
        /*配送方式*/
        case 10:
            return "鑫方盛物流";
            break;
        case 20:
            return "店内自提";
            break;
    }
}

function changeCopies(is_required, file_copies, original_file) {
    var val

    if (file_copies == 0) {
        val = '不需要资质文件'
        return val
    }

    console.log(file_copies)
    if (file_copies != 0) {
        val = '需要资质文件&nbsp;&nbsp;&nbsp;&nbsp;'
    } else {
        val = '不需要资质文件&nbsp;&nbsp;&nbsp;&nbsp;'
    }
    if (file_copies >= 4) {
        val += file_copies + '份&nbsp;&nbsp;&nbsp;&nbsp;'
    } else {
        val += file_copies + '份&nbsp;&nbsp;&nbsp;&nbsp;'
    }

    if (original_file == 10) {
        val += '带红章'
    } else if (original_file == 20) {
        val += '不带红章'
    }
    return val;
}


function changeInvoiceType(invoiceType) {
    switch (invoiceType) {
        /*发票类型*/
        case 10:
            return "增值税";
            break;
        case 20:
            return "普税";
            break;
    }
}

function changeCancleReason(cancleReason) {
    switch (cancleReason) {
        /*取消原因*/
        case 10:
            return "订购错误";
            break;
        case 11:
            return "价格高";
            break;
        case 12:
            return "无法满足到货时效";
            break;
        case 13:
            return "支付问题";
            break;
        case 14:
            return "重复下单";
            break;
        case 15:
            return "暂时不需要";
            break;
        case 16:
            return "订单信息有误";
            break;
        case 17:
            return "无货";
            break;
        case 18:
            return "其他";
            break;
        case 19:
            return "商品质量问题";
            break;
        case 20:
            return "价格错误";
            break;
        case 90:
            return "系统自动取消";
            break;
        case 100:
            return "公司产品原因";
            break;
        case 101:
            return "客户原因";
            break;
        case 102:
            return "用户审批驳回取消";
            break;
    }
}

function changeCloseReason(closeReason) {
    switch (closeReason) {
        /*关闭原因*/
        case 10:
            return "商品质量问题";
            break;
        case 20:
            return "大小/型号与商品描述不符";
            break;
        case 30:
            return "颜色/图案与商品描述不符";
            break;
        case 40:
            return "功能/效果与商品描述不符";
            break;
        case 50:
            return "商城发错货";
            break;
        case 60:
            return "少件/漏件";
            break;
        case 70:
            return "多买/买错不想要了";
            break;
        case 80:
            return "到货物流破损";
            break;
        case 90:
            return "发票问题";
            break;
        case 100:
            return "未按约定时间发货";
            break;
        case 110:
            return "其他原因";
            break;
    }
}

/*渲染页面*/

/*头部按钮*/

function affirmMoney() {
    /*确认认款*/
    layer_show("确认收款", "affirmMoneyAlert.html", "600", "300");
}

/*跳转拒收页面*/
function clientRejection(title, url) {
    var index = layer.open({
        type: 2,
        title: title,
        content: url
    });
    layer.full(index);

}

var isIngReturn = false;

function returnGoods(title) {
    if (isIngReturn) {
        // layer.msg('请求已提交，请勿重复点击！');
        return false;
    }
    isIngReturn = true;
    getOrderDetail();
    setTimeout(function() {
        var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
        var orderState = orderDetail.orderBase.order_status;
        if (orderState == "70") {
            var url = "orderSuccess_refund.html";
        } else if (orderState == "80") {
            var url = "orderSuccess_refund.html";
        } else if (orderState == "90") {
            var url = "orderSuccess_refund.html";
        }
        var index = layer.open({
            type: 2,
            title: title,
            content: url
        });
        layer.full(index);
    }, 200)
}
function detailCancel() {
    sessionStorage.setItem("stater", "1");
    layer_show("提示", "cancleAlert.html", "600", "300");
}

function cancelorder() {
    var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
    var orderState = orderDetail.orderBase.order_status;
    sessionStorage.setItem("stater", "2");
    if (orderState == 40 || orderState == 50) {
        var index = layer.open({
            type: 2,
            title: "订单拦截",
            content: "../channelorder/cancelOrder/orderSuccess_refund2.html",
        });
        layer.full(index);
    } else {
        layer_show("提示", "cancleAlert.html", "600", "300");
    }
}


var dataSource = new Array();
//table的数据源
var table; //table对象
dataSource = [];

function renderOrderPage(data) {
    console.log(data)
        /*商品总金额计算*/
    var goodsAmount = 0;
    if (data.listOrderItems != null) {

        for (var i = 0; i < data.listOrderItems.length; i++) {
            goodsAmount += Number(data.listOrderItems[i].sale_price) * Number(data.listOrderItems[i].buyyer_count);
        }

    }
    $("#goodsAmount").html(goodsAmount.toFixed(2));
    $("#orderAmount").html((goodsAmount + data.orderBase.shipping_fee).toFixed(2));
    /*转换状态*/
    var order_status = changeOrderState(data.orderBase.order_status);
    $("#orderState").html(order_status);
    if (data.orderCancleApply != null) {
        $("#cancle_reason").html(data.orderCancleApply.cancle_reason);
        if (data.orderCancleApply.cancle_reason == 10) {
            $("#cancle_reason").html('订购错误');
        } else if (data.orderCancleApply.cancle_reason == 11) {
            $("#cancle_reason").html('价格高');
        } else if (data.orderCancleApply.cancle_reason == 12) {
            $("#cancle_reason").html('无法满足到货时效');
        } else if (data.orderCancleApply.cancle_reason == 13) {
            $("#cancle_reason").html('支付问题');
        } else if (data.orderCancleApply.cancle_reason == 14) {
            $("#cancle_reason").html('重复下单');
        } else if (data.orderCancleApply.cancle_reason == 15) {
            $("#cancle_reason").html('暂时不需要了');
        } else if (data.orderCancleApply.cancle_reason == 16) {
            $("#cancle_reason").html('订单信息有误');
        } else if (data.orderCancleApply.cancle_reason == 17) {
            $("#cancle_reason").html('无货');
        } else if (data.orderCancleApply.cancle_reason == 18) {
            $("#cancle_reason").html('其他');
        } else if (data.orderCancleApply.cancle_reason == 19) {
            $("#cancle_reason").html('商品质量问题');
        } else if (data.orderCancleApply.cancle_reason == 20) {
            $("#cancle_reason").html('价格错误');
        } else if (data.orderCancleApply.cancle_reason == 90) {
            $("#cancle_reason").html('系统自动取消');
        } else if (data.orderCancleApply.cancle_reason == 100) {
            $("#cancle_reason").html('公司产品原因');
        } else if (data.orderCancleApply.cancle_reason == 101) {
            $("#cancle_reason").html('客户原因');
        } else if (data.orderCancleApply.cancle_reason == 102) {
            $("#cancle_reason").html('用户审批驳回取消');
        }
        $("#order_statue1").html("<span class=\"list\" id='" + data.orderCancleApply.id + "' onclick='dealmodal(" + data.orderCancleApply.id + ")'>驳回</span>")
        $("#order_statue2").html("<span class=\"list\" id='" + data.orderCancleApply.id + "' onclick='dealdemo(" + data.orderCancleApply.id + ")'>跟进</span>")
            /*$("#order_statue3").html("<span class=\"list\" id='"+data.orderCancleApply.id+"' onclick='dealmodaldemo("+data.orderCancleApply.id+")'>退货申请单</span>")*/


    } else {
        $("#cancle_reason").html("");
    }


    $("#dorderId").html(data.channel_order_id);
    $("#orderId").html(data.orderBase.order_id);

    var d = new Date(data.created_order_at);
    var atq = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
    console.log(atq)
    $("#creatOrderTime").html(atq);
    $("#creatOrderTimes").html(data.push_order_at);

    $("#customerName").html(data.parent_customer_name);
    $("#buyerName").html(data.buyer_name);
    $("#receiverDetailAddress3").html(data.receiver_company_name);
    $("#created-osrder-codde").html(data.invoice_company_name);

    $("#channelShippingFee").html(data.channel_shipping_fee);
    $("#dockShippingFee").html(data.dock_shipping_fee);
    $("#yuncai_shipping_fee").html(data.yuncai_shipping_fee);

    //渠道收货地址
    var channelAreaAddress = "";

    if (data.channelProvinceName == null || data.channelProvinceName == "") {
        channelAreaAddress = channelAreaAddress.concat(data.channelProvinceCode, data.channelCityCode, data.channelAreaCode, data.channelTownCode);
    } else {
        channelAreaAddress = channelAreaAddress.concat(data.channelProvinceName, data.channelCityName, data.channelAreaName, data.channelTownName);
    }
    $("#channelAreaAddress").html(channelAreaAddress);
    $("#performingPartyName").html(data.performingPartyName);
    //备注反显
    if (data.listOrderRemark != null) {

        for (var i = 0; i < data.listOrderRemark.length; i++) {
            if (data.listOrderRemark[i].operate_type == 30) {
                if (data.listOrderRemark[i].remark != null) {
                    $("#returnReason").html("全部拒收（" + data.listOrderRemark[i].remark + ")")
                } else {
                    $("#returnReason").html("全部拒收")
                }
                $("#closeOptioner").html(data.listOrderRemark[i].operate_username);
            } else if (data.listOrderRemark[i].operate_type == 40) {
                $("#closeOptioner").html(data.listOrderRemark[i].operate_username);
                if (data.listOrderRemark[i].remark != null) {
                    $("#returnReason").html("全部退货（" + data.listOrderRemark[i].remark + ")");
                } else {
                    $("#returnReason").html("全部退货");
                }

            } else if (data.listOrderRemark[i].operate_type == 50) {
                $("#customServiceRemark").text(data.listOrderRemark[i].remark); //客服备注
            } else if (data.listOrderRemark[i].operate_type == 60) {
                $("#fareSeasonBox").css({
                    display: "inline"
                });
                $("#changeFareSeason").text(data.listOrderRemark[i].remark); //运费备注
            } else if (data.listOrderRemark[i].operate_type == 80) {
                $("#daikess").css({
                    display: "inline"
                });

                $("#coptgifes").text(data.listOrderRemark[i].remark); //代客下单运费备注
            } else if (data.listOrderRemark[i].operate_type == 70) {
                $("#dafdgikess").css({
                    display: "inline"
                });
                $("#coptgvifes").text(data.listOrderRemark[i].remark); //订单运费备注
            } else if (data.listOrderRemark[i].operate_type == 70 || data.listOrderRemark[i].operate_type == 80) {
                $("#dafdgikess").css({
                    display: "inline"
                });
                $("#daikess").css({
                    display: "inline"
                });

                $("#coptgifes").text(data.listOrderRemark[i].remark); //代客下单运费备注
                $("#coptgvifes").text(data.listOrderRemark[i].remark); //订单运费备注
            }

            if (data.listOrderRemark[i].operate_type == 20) {
                if (data.listOrderRemark[i] == null) {
                    $(".orderRemark textarea").val();
                } else {
                    $(".orderRemark textarea").val(data.listOrderRemark[i].remark);
                }
            }
            if (data.listOrderRemark[i].operate_type == 10) {
                if (data.listOrderRemark[i] == null) {
                    $("#comfirmMoneyRemark").val();
                } else {
                    $("#affirmMoney").css({
                        display: "none"
                    })
                    $("#comfirmMoneyRemark").html(data.listOrderRemark[i].remark); //确认认款备注
                }
            }
        }
    }

    if (data.orderRemark != null) {
        $("#comfirmRemark").text(data.orderRemark.remark)
    }

    if (data.orderExt && data.orderExt.new_customer_name) {
        $("#newCustomerName").text(data.orderExt.new_customer_name)
    }
    /*是否是异常订单*/
    var abnormalType = "";
    var abnormalTypeArr = [];
    if (data.exception_type == null || data.exception_type == undefined || data.exception_type == "") {
        $("#abnormalType").html('')
    } else {
        var rowArr = data.exception_type.split(',');

        function getAbnormalType(typeCode) {
            switch (typeCode) {
                case "10":
                    return "无异常";
                    break;
                case "20":
                    return "大额订单";
                    break;
                case "30":
                    return "超可用额度";
                    break;
                case "40":
                    return "超卖订单";
                    break;
                case "50":
                    return "低于成本价";
                    break;
                case "60":
                    return "结算价异常";
                    break;
                case "70":
                    return "非我司商品";
                    break;
                case "80":
                    return "商品已下架";
                    break;
                case "90":
                    return "商品无结算价";
                    break;
                case "100":
                    return "运费金额异常";
                    break;
                case "110":
                    return "超可执行赊欠额度";
                    break;
                case "120":
                    return "临采商品订单";
                    break;
                case "130":
                    return "危险品订单";
                    break;
                case "140":
                    return "经纬度异常";
                    break;
                case "150":
                    return "议价单异常";
                    break;
                case "160":
                    return "服务商商品";
                    break;
            }
        }

        for (var i = 0; i < rowArr.length; i++) {
            abnormalTypeArr.push(getAbnormalType(rowArr[i]));
        }
        for (var j = 0; j < abnormalTypeArr.length; j++) {
            if (j < abnormalTypeArr.length - 1) {
                abnormalType += abnormalTypeArr[j] + ";";
            } else {
                abnormalType += abnormalTypeArr[j] + "";
            }
        }
        $("#abnormalType").html(abnormalType)
    }


    /*取消订单记录*/
    if (data.orderCancle != null) {
        $("#cancleTime").html(data.orderCancle.created_at);
        $("#optioner").html(data.orderCancle.cancle_name);
        $("#cancle-reason").html(changeCancleReason(data.orderCancle.cancle_reason));
        $("#cancle-info").html(data.orderCancle.cancel_remark);
    }
    /*关闭订单记录*/
    if (data.orderRefund != null) {
        var d = new Date(data.orderRefund.created_at);
        var at = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
        $("#closeTime").html(at);
        // $("#closeOptioner").html(data.orderRefund.operate_username);
        $("#close-reason").html(changeCloseReason(data.orderRefund.refund_reason));
        $("#close-info").html(data.orderRefund.refund_desc);
    }
    /*基本信息*/

    $("#buyer-name").html(data.customer_name);

    $("#created-order-code").html(data.buyer_name);
    $("#departmentName").html(data.channelDepartmentName);

    /*if (data.orderExt.sent_type == 50) {
        $("#alisaAddress").html("");
    } else {
        $("#alisaAddress").html(data.channelProjectName);
    }*/
    $("#alisaAddress").html(data.channelProjectName);
    $("#departmentName").html(data.channelDepartmentName);

    $("#receiver-address").html(data.orderExt.receiver_province_name + "" + data.orderExt.receiver_city_name + "" + data.orderExt.receiver_area_name + "" + data.orderExt.receiver_town_name + "" + data.orderExt.receiver_detail_address);
    var receiveDetailAddress = data.orderExt.receiver_province_name + "" + data.orderExt.receiver_city_name + "" + data.orderExt.receiver_area_name + "" + data.orderExt.receiver_town_name + "" + data.orderExt.receiver_detail_address;
    sessionStorage.setItem("receiveDetailAddress", receiveDetailAddress);
    $("#consignee").html(calculate(data.listAddressReceiver, 1));
    sessionStorage.setItem("consignee", calculate(data.listAddressReceiver, 1));
    $("#contact-way").html(calculate(data.listAddressReceiver, 2));
    //授权收货人
    $("#cell-phone-number").html(calculate(data.listAddressReceiver, 2));
    $("#sales-manager").html(data.orderExt.sales_manager_name + "&nbsp;&nbsp;" + data.orderExt.sales_manager_phone);
    if (data.orderExt.platform == 10) {
        $("#platform").html("普通平台");
    } else if (data.orderExt.platform == 20) {
        $("#platform").html("签约平台");
    }

    $("#contact-phone").html(data.orderExt.sales_manager_phone);
    $("#email").html(data.orderExt.customer_email);

    /*鼠标移出事件*/
    $("#consignee").mouseover(function() {
        $("#mouseBox").show();
        $("#mouseBox").html(calculate(data.listAddressReceiver, 1));
    }).mouseout(function() {
        $("#mouseBox").hide();
    })
    $("#cell-phone-number").mouseover(function() {
            $("#mouseBoxTwo").show();
            $("#mouseBoxTwo").html(calculate(data.listAddressReceiver, 3))
            sessionStorage.setItem("mouseBoxTwo", calculate(data.listAddressReceiver, 3))
        }).mouseout(function() {
            $("#mouseBoxTwo").hide();
        })
        //固话
    $("#linePhone").html(data.orderExt.customer_landline_phone);
    /* 渲染开票信息*/
    renderInvoiceInfo(data);
    /*if(data.orderBase.role_name == " "){
        $("#replaceBox").hide();
    }else {
        $("#replace-man").html(data.orderBase.role_name);
    }*/
    /*支付与配送方式*/
    $("#pay-type").html(data.initPayWay);
    // $("#delivery-method").html(data.orderExt.sent_type);

    if (data.orderExt.sent_type) {
        $("#delivery-method").html(deliverTypeArr[data.orderExt.sent_type]);
    }

    // if (data.orderExt.sent_type == 10) {
    //     $("#delivery-method").html('快递')
    // } else if (data.orderExt.sent_type == 20) {
    //     $("#delivery-method").html('快运-送货上门')
    // } else if (data.orderExt.sent_type == 21) {
    //     $("#delivery-method").html('快运-站点自提')
    // } else if (data.orderExt.sent_type == 30) {
    //     $("#delivery-method").html('专车包车')
    // } else if (data.orderExt.sent_type == 40) {
    //     $("#delivery-method").html('鑫方盛物流')
    // } else if (data.orderExt.sent_type == 50) {
    //     $("#delivery-method").html('上门自提')
    // }

    //上门自提
    $("#self_take_in").html(data.self_take_in_str);
    $("#self_take_shop").html(data.orderExt.self_take_shop);
    $("#receiver_detail_address").html(data.orderExt.receiver_province_name + data.orderExt.receiver_city_name + data.orderExt.receiver_detail_address);
    $("#self_take_phone").html(data.orderExt.self_take_phone);
    if (data.orderWarning != "" && data.orderWarning != null) {

        $("#relieve_role").html(data.orderWarning.login_account);
        $("#operated_at").html(data.orderWarning.operated_at);
    }

    if (data.orderInvoice != "" && data.orderInvoice != null) {
        if (data.orderInvoice.invoice_remark != "" && data.orderInvoice.invoice_remark != null) {
            $("#invoiceremark").html(data.orderInvoice.invoice_remark);
        } else {
            $("#invoiceremark").html("无");
        }

    } else {
        $("#invoiceremark").html("无");
    }


    //运费
    $("#shippingfee").html((data.orderBase.init_shipping_fee).toFixed(2));
    var yunf = "";
    if (data.orderCoupon != "") {
        if (data.orderBase.used_coupon == 10 && data.orderCoupon.coupon_type == 20) {
            if (data.orderBase.separate_shipping_fee == 10) {
                yunf = (data.orderBase.shipping_fee - data.orderCoupon.coupon_real_value).toFixed(2) + '元' + '&nbsp;&nbsp;' + "(运费单开)"
            } else {
                yunf = data.actual_shipping_fee + '元' + '&nbsp;&nbsp;' + "(运费分摊)"
            }

        } else {
            if (data.orderBase.separate_shipping_fee == 10) {
                yunf = (data.orderBase.shipping_fee).toFixed(2) + '元' + '&nbsp;&nbsp;' + "(运费单开)"
            } else {
                yunf = data.actual_shipping_fee + '元' + '&nbsp;&nbsp;' + "(运费分摊)"
            }

        }
    }


    $("#couponrealvalue").html(yunf);

    $("#freight").html((data.orderBase.shipping_fee).toFixed(2));

    $("#appointment-time").html(data.orderExt.wanna_arrived_in);
    if (data.orderExt.wanna_arrived_in == '1000-01-01 00:00:00') {
        $("#appointment-time").html("");
    } else if (data.orderExt.wanna_arrived_in == null) {

        $("#appointment-time").html("");
    } else {
        $("#appointment-time").html(data.orderExt.wanna_arrived_in);

    }

    //预计送达时间

    if (data.orderExt.may_arrived_in != null) {
        if (data.orderExt.may_arrived_in == '1000-01-01 00:00:00') {
            $("#predixt-delivery-time").html("");
        } else if (data.orderExt.may_arrived_in == null) {

            $("#predixt-delivery-time").html("");
        } else {
            if (data.orderExt.sent_type == 40) {
                var d = new Date(data.orderExt.may_arrived_in);
                var hour = d.getHours();
                var Minutes = d.getMinutes();
                var Second = d.getSeconds();
                console.log(d.getHours());
                if (d.getHours() < 10) {
                    hour = "0" + hour
                }
                if (d.getMinutes() == 0) {
                    Minutes = "00"
                }
                if (d.getSeconds() == 0) {
                    Second = "00"
                }
                if (d.getSeconds() < 10 && d.getSeconds() != 0) {
                    Second = "0" + Second
                }

                // var arrived=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()+ ' ' + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
                var arrived = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + hour + ":" + Minutes + ":" + Second;
                $("#predixt-delivery-time").html(arrived)
            } else {
                var d = new Date(data.orderExt.may_arrived_in);
                var arrived = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
                $("#predixt-delivery-time").html(arrived)
            }

        }


    } else {
        $("#predixt-delivery-time").html("")
    }


    //期望送达时间
    if (data.orderExt.wanna_arrived_in != null) {
        if (data.orderExt.wanna_arrived_in == '1000-01-01 00:00:00') {
            $("#predixt-delivery-time").html("");
        } else if (data.orderExt.wanna_arrived_in == null) {

            $("#predixt-delivery-time").html("");
        } else {
            if (data.orderExt.sent_type == 40) {
                var d1 = new Date(data.orderExt.wanna_arrived_in);
                var hour1 = d1.getHours();
                var Minutes1 = d1.getMinutes();
                var Second1 = d1.getSeconds();
                console.log(d1.getHours());
                if (d1.getHours() < 10) {
                    hour1 = "0" + hour1
                }
                if (d1.getMinutes() == 0) {
                    Minutes1 = "00"
                }
                if (d1.getSeconds() == 0) {
                    Second1 = "00"
                }
                if (d1.getSeconds() < 10 && d1.getSeconds() != 0) {
                    Second1 = "0" + Second1
                }
                var arrived1 = d1.getFullYear() + '-' + (d1.getMonth() + 1) + '-' + d1.getDate() + ' ' + hour1 + ":" + Minutes1 + ":" + Second1;
                $("#wanna_arrived_in").html(arrived1)
            } else {
                var d2 = new Date(data.orderExt.wanna_arrived_in);
                var arrived2 = d2.getFullYear() + '-' + (d2.getMonth() + 1) + '-' + d2.getDate();
                $("#wanna_arrived_in").html(arrived2)
            }
        }

        // var d = new Date(data.orderExt.wanna_arrived_in);
        // var wannaarri=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() ;
        // $("#wanna_arrived_in").html(wannaarri)
    } else {
        $("#wanna_arrived_in").html("")
    }
    if (data.arrived_type != "" || data.arrived_type != null) {
        if (data.arrived_type == 10) {
            $("#peisong-time").html("任何时间送货")
        } else if (data.arrived_type == 20) {
            $("#peisong-time").html("工作日送货")
        }
    } else {
        $("#peisong-time").html("")
    }


    //DC仓发货人
    if (data.orderExt.express_company == null) {
        $("#express_company").val("")
    } else {
        /*$("#express_company").val(data.orderExt.express_company+data.orderExt.express_num);*/
        $("#express_company").val(data.orderExt.express_num)
    }
    //快递公司
    if (data.orderExt.express_company == null) {
        $("#express_company2").val("")
    } else {
        $("#express_company2").val(data.orderExt.express_company);
    }
    //询价单号
    $("#inquiry_num").html(data.inquiry_num)
        //快递单号
    if (data.orderExt.express_num == null) {
        $("#express_num").val("")
    } else {
        console.log(data.orderExt.express_num)
        $("#express_num").val(data.orderExt.express_num);
    }


    if (data.orderBase.order_status == 9 || data.orderBase.order_status == 10 || data.orderBase.order_status == 20 || data.orderBase.order_status == 30 || data.orderBase.order_status == 40 || data.orderBase.order_status == 50) {

        $("#final_sent option:selected").val("")
    } else {
        $("#final_sent").val(data.orderExt.final_sent_type);
    }


    if (data.orderBase.order_status == 20 && data.exception_type.match(150)) {
        $("#gh").css({
            display: "block"
        });
    }

    if (data.orderBase.order_status == 20 && data.exception_type == 150) {
        $("#xg").css({
            display: "block"
        });
    }

    //快运公司
    if (data.orderExt.express_company == null) {
        $("#express_company3").val("")
    } else {
        console.log(data.orderExt.express_company)
        $("#express_company3").val(data.orderExt.express_company);
    }
    //快运单号
    if (data.orderExt.express_num == null) {
        $("#express_num3").val("")
    } else {
        console.log(data.orderExt.express_num)
        $("#express_num3").val(data.orderExt.express_num);
    }


    //结算金额
    $("#settlement-amount").html(data.orderBase.paid_amount);
    //付款方式
    $("#money-type").html(data.payWay);

    //结算方式
    $("#settlement-method").html(data.settleWay);

    //司机名称和电话

    if (data.orderExt.final_sent_type == 40 || data.orderBase.order_status != 60) {
        if (data.orderExt.driver_name != null && data.orderExt.driver_phone != null) {
            $("#driver-phone").val(data.orderExt.driver_name + data.orderExt.driver_phone);
        }
    } else {
        $("#driver-phone").val(data.orderExt.express_company);

    }

    //配送员名称和电话

    if (data.orderExt.final_sent_type == 40 || data.orderBase.order_status != 60) {
        console.log(123, "123" + data.orderExt.deliver_phone);
        if (data.orderExt.deliver_name == null && data.orderExt.deliver_phone == null) {
            $("#distributor-phone").val('');
        } else if (data.orderExt.deliver_name != null && data.orderExt.deliver_phone == null) {
            $("#distributor-phone").val(data.orderExt.deliver_name);
        } else {
            $("#distributor-phone").val(data.orderExt.deliver_name + data.orderExt.deliver_phone);
        }
    } else {
        if (data.orderExt.express_num) {
            $("#distributor-phone").val('');
        } else {
            $("#distributor-phone").val(data.orderExt.express_num);
        }
    }


    /*发票信息*/
    if (data.orderInvoice != null) {

        if (data.orderInvoice.invoice_type == null || data.orderInvoice.invoice_type == '') {
            $("#invoice-type").html("个人(不开)")
        }
        if (data.orderInvoice.invoice_type == 20 && data.orderInvoice.invoice_title == '个人') {
            $("#invoice-type").html('普通发票' + '&nbsp;&nbsp;' + data.orderInvoice.invoice_title)
        } else {
            $("#invoice-type").html('普通发票')
            $("#invoice_title").html(data.orderInvoice.invoice_title)
            $("#taxpayer_identify_num").html(data.orderInvoice.taxpayer_identify_num)
        }
        if (data.orderInvoice.invoice_type == 10) {
            $("#invoice-type").html('增值税专用发票')
            $("#invoice_title").html(data.orderInvoice.invoice_title)
            $("#taxpayer_identify_num").html(data.orderInvoice.taxpayer_identify_num)
            $("#register_address").html(data.orderInvoice.register_address)
            $("#register_phone").html(data.orderInvoice.register_phone)
            $("#open_bank").html(data.orderInvoice.open_bank)
            $("#bank_account").html(data.orderInvoice.bank_account)
        }
        $("#invoice-title").html(data.orderInvoice.invoice_title);
        $("#invoice-content").html(data.orderInvoice.invoice_content);

        $("#invoice-title").html(data.orderInvoice.invoice_title);
        $("#invoice-content").html(data.orderInvoice.invoice_content);
    } else {
        $("#invoice-type").html("个人(不开)")
    }
    /*优惠券信息*/
    if (data.orderCoupon == null) {
        $("#couponInfo").html("无")
    } else {
        $("#couponInfo").html("满" + data.orderCoupon.use_condition + "元减" + data.orderCoupon.coupon_value + "元")
    }
    if (data.orderCoupon == null) {
        $("#couponInfsfo").html("无")
    } else {
        $("#couponInfsfo").html("满" + data.orderCoupon.use_condition + "元减" + data.orderCoupon.coupon_value + "元")
    }


    $("#longestside").html((data.max_edge).toFixed(3) + 'm')

    if (data.total_volume < 0.01) {
        $("#volume").html("小于0.01m³")
    } else {
        //$("#volume").html( (data.total_volume_f).toFixed(3)+'m³')
        $("#volume").html((parseFloat(data.total_volume)).toFixed(3) + 'm³')
    }
    console.log("体积为", data.total_volume);

    $("#weight").html((data.total_weight).toFixed(3) + 'kg')


    /*结算信息*/
    if (data.orderBase.separate_shipping_fee == 10) {
        console.log((data.orderBase.final_total_amount - data.orderBase.shipping_fee - (data.total_promotion_value - data.full_amount_reduce_value - data.full_quantity_reduce_value)).toFixed(2))
        $("#goodsAmount").html((data.orderBase.final_total_amount - data.orderBase.shipping_fee - (data.total_promotion_value - data.full_amount_reduce_value - data.full_quantity_reduce_value)).toFixed(2)); //商品金额
        $("#fare").html((data.orderBase.shipping_fee).toFixed(2)); //运费
    } else {
        $("#goodsAmount").html((data.orderBase.final_total_amount - data.orderBase.shipping_fee - (data.total_promotion_value - data.full_amount_reduce_value - data.full_quantity_reduce_value) + data.orderBase.shipping_fee).toFixed(2)); //商品金额
        $("#fare").html("0.00"); //运费
    }

    if (data.orderCoupon != null && data.orderCoupon.coupon_type == 10) {
        var aaa = 0;
        $("#littleFare").html(aaa.toFixed(2)); //运费减免
        if (data.orderCoupon == null) {
            $("#conMoney").html(aaa.toFixed(2)); //优惠券
        } else {
            $("#conMoney").html((data.orderCoupon.coupon_real_value).toFixed(2)); //优惠券
        }
    } else {
        var aaa = 0;
        $("#conMoney").html(aaa.toFixed(2)); //优惠券
        if (data.orderCoupon == null) {
            $("#littleFare").html(aaa.toFixed(2)); //运费减免
        } else {
            $("#littleFare").html((data.orderCoupon.coupon_real_value).toFixed(2)); //运费减免
        }
    }
    //促销立减

    $("#cuxiao").html((data.full_amount_reduce_value + data.full_quantity_reduce_value).toFixed(2));
    var used_total_points = ""
    if (data.orderBase.used_total_points != null) {

        used_total_points = (data.orderBase.used_total_points).toFixed(2)

    } else {
        used_total_points = "0.00"
    }
    $("#integral").html(used_total_points);
    $("#orderAmount").html((data.orderBase.paid_amount).toFixed(2)); //订单金额

    /*资质文件信息*/
    $("#copies").html(changeCopies(data.orderBase.quality_file_required, data.orderExt.file_copies, data.orderExt.original_file));
    /*商品信息*/
    /*	dataSource.splice(0, dataSource.length); //清空数组
        $.each(data.listOrderItems, function(i, field) {
            console.log(data.listOrderItems)
            var rowData = new Array();
            rowData.push(field.product_pic);
            rowData.push(field.warehouse_id);
            rowData.push(field.buyyer_count);
            rowData.push(field.delivery_count);
            rowData.push(field.receive_count);
            rowData.push(field.have_returned_count);
            rowData.push(field.sale_price);
            rowData.push(field.order_id);
            rowData.push(field.sku_code);
            rowData.push(field.product_name);
            rowData.push(field.sku_info);
            rowData.push(field.unit_name);
            rowData.push(field.spu_id);
            rowData.push(field.color);
            dataSource.push(rowData);
        });
        initDataTable(dataSource);

        function initDataTable(dataSource) {
            var dttable = $('#datatable').dataTable(); // 初始化dataTable，清空上一个值
            dttable.fnClearTable(); //清空一下table
            dttable.fnDestroy(); //还原初始化了的datatable
            $("#datatable").DataTable({
                "autoWidth": false,
                "ordering": true,
                "searching": true,
                "paging": true,
                "retrieve": true,
                "destroy": true,
                "bAutoWidth": true,
                "bLengthChange": true,
                "aLengthMenu": [5, 10, 25, 50],
                "oLanguage": {
                    "sLengthMenu": "每页显示 _MENU_ 条记录",
                    "sZeroRecords": "抱歉， 没有找到",
                    "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
                    "sInfoEmpty": "没有数据",
                    "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
                    "oPaginate": {
                        "sFirst": "首页",
                        "sPrevious": "前一页",
                        "sNext": "后一页",
                        "sLast": "尾页"
                    },
                    "sZeroRecords": "没有检索到数据",
                    "sProcessing": "<img src='./loading.gif' />"
                },
                data: dataSource,
                columnDefs: [{
                        "visible": true,
                        "targets": 0
                    },
                    {
                        "render": function(data, type, row) {
                            if(row[12]==0){
                                var val = '<div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="'+row[0]+'" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + row[8] + '</div><div>' + row[9] + '</div><div>' + row[13] + '</div><div>' + row[10] + '</div></div></div>';

                            }else {
                                var val = '<div style="cursor:pointer;"><img title="点击跳转sku列表" onclick="goToGoodsDetail(' + row[12] + ')" style="float: left;width: 100px;height: 100px;" name="" src="'+row[0]+'" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + row[8] + '</div><div>' + row[9] + '</div><div>' + row[13] + '</div><div>' + row[10] + '</div></div></div>';

                            }
                            return val;
                        },
                        "targets": 0
                    },
                    {
                        "render": function(data, type, row) {
                            var whereHouse
                            if (row[1]==0 || row[1]==null){
                                whereHouse=""
                            }
                            if(row[1] == 1) {
                                whereHouse = "北京仓";
                            }
                            if(row[1] == 2) {
                                whereHouse = "天津仓";
                            }
                            if(row[1] == 4) {
                                whereHouse = "郑州仓";
                            }
                            var val = '<span>' + whereHouse + '</span>';
                            return val;
                        },
                        "targets": 1
                    },
                    {
                        "render": function(data, type, row) {
                            var val = '<span>' + row[2] + '' + row[11] + '</span>';
                            return val;
                        },
                        "targets": 2
                    },
                    {
                        "render": function(data, type, row) {
                            var val = '<span>' + row[3] + '' + row[11] + '</span>';
                            return val;
                        },
                        "targets": 3
                    },
                    {
                        "render": function(data, type, row) {

                            var val = '<span>' + row[4] + '' + row[11] + '</span>';
                            return val;
                        },
                        "targets": 4
                    },
                    {
                        "render": function(data, type, row) {
                            var val = '<span>' + row[5] + '' + row[11] + '</span>';
                            return val;
                        },
                        "targets": 5
                    },

                    {
                        "render": function(data, type, row) {
                            var price = row[6].toFixed(2);
                            var val = '<span>' + price + '元/' + row[11] + '</span>';
                            return val;
                        },
                        "targets": 6
                    },
                    {
                        "render": function(data, type, row) {
                            var substotle=(row[6] * row[2]).toFixed(2);
                            var val = '<span>' + substotle + '元'+'</span>';
                            return val;
                        },
                        "targets": 7
                    }
                ]
            });
        };*/


}

/*跳转退货订单详情*/
function returnOrderInfo(title, url, returnId, orderId) {
    sessionStorage.setItem("returnId", returnId);
    sessionStorage.setItem("returnOrderId", orderId);
    var index = layer.open({
        type: 2,
        title: title,
        content: url,
        /* 关闭弹出框的回调函数*/
        end: function() {
            location.replace(location.href)
        }
    });
    layer.full(index);
}

/*新用户名称编辑*/
var customerOldVal = "";
var $customerTextarea = $(".new-customer-name textarea");
var $saveCustomerBtn = $("#saveCustomerBtn");
var $editCustomerBtn = $("#editCustomerBtn");
var $errorMsg = $(".new-customer-name .errorMsg");

function editCustomer() {
    customerOldVal = $customerTextarea.val();
    $saveCustomerBtn.show();
    $editCustomerBtn.hide();
    $customerTextarea.removeAttr("readonly");
}

function cancleCustomerEdit() {
    $customerTextarea.val(customerOldVal);
    $saveCustomerBtn.hide();
    $editCustomerBtn.show();
    $customerTextarea.attr("readonly", "readonly");
    setTextareaErrStyle(false);
}

function setTextareaErrStyle(isError) {
    if (isError) {
        $customerTextarea.css({
            border: "1px red solid"
        });
        $errorMsg.css({
            display: "inline"
        });
    } else {
        $customerTextarea.css({
            border: "1px #ddd solid"
        });
        $errorMsg.css({
            display: "none"
        });
    }
}

function saveCustomer() {
    if ($customerTextarea.val().length == 0 || $customerTextarea.val().length > 60) {
        setTextareaErrStyle(true);
    } else {
        setTextareaErrStyle(false);
        var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
        var params = {
            orderId: orderDetail.orderBase.order_id,
            operatorId: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
            operatorName: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
            newCustomerName: $customerTextarea.val()
        }
        var succCallBack = function(data) {
            if (data.errorCode == 0) {
                location.replace(location.href);
                cancleCustomerEdit();
            } else {
                layer.msg(data.message, { icon: 5, time: 2000 });
            }
        }
        web.doAjax(root.dockingplatform.saveOrderExtNewCustomerName, 'post', params, succCallBack, 1);
    }
}

/*订单备注编辑*/
var oldVal = "";

function toEdit() {
    oldVal = $(".orderRemark textarea").val();
    $("#isSaveFalse").css({
        display: "none"
    });
    $("#isSaveTrue").css({
        display: "block"
    });
    $(".orderRemark textarea").removeAttr("readonly");
}

function toCancle() {
    $(".orderRemark textarea").val(oldVal);
    $("#isSaveFalse").css({
        display: "block"
    });
    $("#isSaveTrue").css({
        display: "none"
    });
    $(".orderRemark textarea").css({
        border: "1px #ddd solid"
    });
    $(".orderRemark .errorMsg").css({
        display: "none"
    });
    $(".orderRemark textarea").attr("readonly", "readonly");
}

function remarkToSave() {
    if ($(".orderRemark textarea").val().length > 500) {
        $(".orderRemark textarea").css({
            border: "1px red solid"
        });
        $(".orderRemark .errorMsg").css({
            display: "inline"
        });

    } else {
        $(".orderRemark textarea").css({
            border: "1px #ddd solid"
        });
        $(".orderRemark .errorMsg").css({
            display: "none"
        });
        var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
        var orderState = orderDetail.orderBase.order_status;

        function btnDisplay() {
            $("#isSaveFalse").css({
                display: "block"
            });
            $("#isSaveTrue").css({
                display: "none"
            });
            $(".orderRemark textarea").attr("readonly", "readonly");
        }

        /*进行添加备注请求*/
        var odata = {}
        var ourl = ""
        if (ordersts == 20 || ordersts == 10 || ordersts == 100) {
            ourl = 'https://' + window.location.host + '/api/admin/apreorder/remark/saveOrderRemark';
            odata = {
                bus_id: orderDetail.orderBase.order_id,
                operate_userid: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                operate_username: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
                remark: $("#comfirmRemark").val()
            };
        } else {
            ourl = root.orderInter.order_saveOrderRemark;
            odata = {
                bus_id: orderDetail.orderBase.order_id,
                operate_userid: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                operate_username: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
                remark: $("#comfirmRemark").val()
            }
        }
        // $.ajax({
        //     contentType: "application/json",
        //     type: "POST",
        //     url: ourl,
        //     cache: false, //禁用缓存
        //     dataType: "json",
        //     data: JSON.stringify(odata),
        //     success: function (result) {
        //         if (result.code == 0) {
        //             location.replace(location.href);
        //         } else {
        //             layer.msg(result.message, {icon: 5, time: 2000});
        //         }
        //     },
        //     error: function (XMLHttpRequest, textStatus, errorThrown) {
        //         alert(XMLHttpRequest);
        //     }
        // });
        var succCallBack = function(data) {
            if (data.code == 0) {
                location.replace(location.href);
                btnDisplay();
            } else {
                layer.msg(data.message, { icon: 5, time: 2000 });
            }
        }
        web.doAjax(root.dockingplatform.saveOrderRemark, 'post', odata, succCallBack, 1);

    }
}

/*详细信息编辑*/
function requireUpdataInter(updataData) {
    $.ajax({
        contentType: "application/json",
        type: "POST",
        url: root.orderInter.order_edit,
        cache: false, //禁用缓存
        dataType: "json",
        data: updataData,
        success: function(result) {
            if (result.code == 0) {
                $("#addressInpBox").css({
                    display: "none",
                });
                location.replace(location.href);
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest);
        }
    });
}

function updataDisplay(ids) {
    $(ids).css({
        display: "block",
    });
}

function updataSure(val) {
    var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
    switch (val) {
        /*修改那个标签*/
        case "#addressInp":
            /*收货地址*/
            var updataData = JSON.stringify({
                order_id: orderDetail.orderBase.order_id,
                receiver_detail_address: $('#addressInp').val(),
            });
            requireUpdataInter(updataData);
            break;
        case "#consigneeInp":
            /*收货人*/
            var updataData = JSON.stringify({
                order_id: orderDetail.orderBase.order_id,
                received_name: $('#consigneeInp').val(),
            });
            requireUpdataInter(updataData);
            break;

        case "#alisaAddressInp":
            /*地址别名*/
            var updataData = JSON.stringify({
                order_id: orderDetail.orderBase.order_id,
                receiver_detail_address_alias: $('#alisaAddressInp').val(),
            });
            requireUpdataInter(updataData);
            break;
        case "#emailInp":
            /*邮箱*/
            var updataData = JSON.stringify({
                order_id: orderDetail.orderBase.order_id,
                customer_email: $('#emailInp').val(),
            });
            requireUpdataInter(updataData);
            break;
        case "#phoneInp":
            /*手机号*/
            var updataData = JSON.stringify({
                order_id: orderDetail.orderBase.order_id,
                received_phone: $('#phoneInp').val(),
            });
            requireUpdataInter(updataData);
            break;
        case "#linePhoneInp":
            /*固定电话*/
            var updataData = JSON.stringify({
                order_id: orderDetail.orderBase.order_id,
                customer_landline_phone: $('#linePhoneInp').val(),
            });
            requireUpdataInter(updataData);
            break;
    }
}

function updataCancel() {

    $("#alisaAddressInpBox").css({
        display: "none",
    });

}

function updataCancel1() {
    $("#addressInpBox").css({
        display: "none",
    });

}

function updataCancel2() {

    $("#consigneeInpBox").css({
        display: "none",
    });
}

function updataCancel3() {
    $("#emailInpBox").css({
        display: "none",
    });
}

function updataCancel4() {
    $("#phoneInpBox").css({
        display: "none",
    });
}

function updataCancel5() {
    $("#linePhoneInpBox").css({
        display: "none",
    });
}

function goToGoodsDetail(spuId) {
    sessionStorage.setItem("spuId", spuId);
    sessionStorage.setItem("spuId_order", spuId);
    var index = layer.open({
        type: 2,
        title: "Code详情",
        content: "../../goods/goods-sku.html"
    });
    layer.full(index);
}


//驳回弹框
var index = 0;

function dealmodal(id, val) {
    var curInd = layer.confirm('<span id="status" style="width:200px;height:100px;resize: none;" maxlength="200" >您确定要驳回吗</span>', {
        title: '提示',
        btn: ['确定', '取消']
    }, function(index) {

        finish1(id, curInd, val)
        layer.close(curInd);
    }, function() {
        layer.close(curInd);

    });
}

function finish1(id, val) {
    var target = document.getElementById('' + id + '');
    /*target.parentElement.parentElement.parentElement.previousElementSibling.innerHTML='关闭';*/
    console.log(target)

    var reason = $('#reason' + id + '').val();
    if (reason != '') {
        $.ajax({
            contentType: "application/json;charset=UTF-8",
            url: root.orderInter.order_rejectCancleApply,
            cache: false, //禁用缓存
            type: "POST",
            dataType: 'json',
            data: JSON.stringify({
                "id": id,
            }),
            success: function(data) {
                console.log(data)

                target.onclick = null;
                target.setAttribute("onclick", 'confirm(' + id + ')')
                    /*target.parentElement.parentElement.parentElement.previousElementSibling.innerHTML='关闭'*/
                getOrderDetail();

            },
            error: function() {
                $.Huimodalalert('失败！', 2000);
            }
        })
    } else {
        $.Huimodalalert('处理结果不能为空！', 2000);
    };
    layer.close(index);
}

function dealdemo(id, val) {
    layer.msg('客服跟进处理！');
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.order_followCancleApply,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            "id": id,
        }),
        success: function(data) {

            getOrderDetail();
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })


}

//退货申请单
var isIngReturn = false;

function returnGoods1(title) {
    if (isIngReturn) {
        // layer.msg('请求已提交，请勿重复点击！');
        return false;
    }
    isIngReturn = true;
    getOrderDetail();
    setTimeout(function() {
        var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
        var orderState = orderDetail.orderBase.order_status;

        var url = "orderSuccess_refund2.html";

        var index = layer.open({
            type: 2,
            title: title,
            content: url
        });
        layer.full(index);
    }, 200)
}

//发货
function Delivergoods() {
    $("#Expresssss").css({
        display: "block"
    });
    if ($("#final_sent_type option:selected").text() == "快递") {
        if (custormerCode == "D000000025") {
            $("#dddd").css({
                display: "block"
            });
        } else {
            $("#bbbb").css({
                display: "block"
            });
        }

        $("#bbbb111").css({
            display: "block"
        });
    } else if ($("#final_sent_type option:selected").text() == "快运") {
        if (custormerCode == "D000000025") {
            $("#aaaa1").css({
                display: "inline"
            });
        } else {
            $("#aaaa").css({
                display: "inline"
            });
        }

        $("#aaa111").css({
            display: "inline"
        });
    } else if ($("#final_sent_type option:selected").text() == "包车专车") {
        $("#cccc").css({
            display: "inline"
        });

        $("#ccc111").css({
            display: "inline"
        });
    }


}

//发货取消快运按钮
function Expresscancel() {
    $("#Expresssss").css({
        display: "none"
    });

}

//发货取消快递按钮
function couriercancel() {
    $("#courier").css({
        display: "none"
    });

}

//发货取消专车包车按钮
function Limousinecancel() {
    $("#Limousine").css({
        display: "none"
    });

}

//发货确认快运按钮
function Expressconfirm() {
    var expresscompany = ''
    var expressnum = ''

    if ($("#final_sent_type option:selected").text() == "快递") {
        if (custormerCode == "D000000025") {
            expresscompany = $("#express_company_two1").val()
        } else {
            expresscompany = $("#express_company_two").val()
        }
        expressnum = $("#express_num_two").val()
    } else if ($("#final_sent_type option:selected").text() == "快运") {
        if (custormerCode == "D000000025") {
            expresscompany = $("#express_company_one1").val()
        } else {
            expresscompany = $("#express_company_one").val()
        }
        expressnum = $("#express_num_one").val()

    } else if ($("#final_sent_type option:selected").text() == "包车专车") {

        expresscompany = $("#driver_name").val() + $("#driver_phone").val()
        expressnum = $("#express_company_three").val()

    }
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.tempDeliver,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            final_sent_type: $("#final_sent_type").val(),
            express_company: expresscompany,
            express_num: expressnum,

        }),
        success: function(data) {
            $("#frglivergoods").css({
                display: "none"
            });
            $("#Expresssss").css({
                display: "none"
            });
            // getOrderDetail();
            location.replace(location.href);
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })

}


//编辑司机
function toassddit1() {
    $("#driver-phone").removeAttr("readonly");

    $("#issdffsfsSaveTrue").css({
        display: "block"
    });
}

function toancle1() {
    $("#driver-phone").attr("readonly", "readonly");

    $("#issdffsfsSaveTrue").css({
        display: "none"
    });
    getOrderDetail();
}

function remaToSave1() {
    $("#driver-phone").attr("readonly", "readonly");
    $("#issdffsfsSaveTrue").css({
        display: "none"
    });

    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.editTempDeliverInfo,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            express_company: $("#driver-phone").val()

        }),
        success: function(data) {
            getOrderDetail();
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

//编辑配送员
function toassddit2() {
    $("#distributor-phone").removeAttr("readonly");

    $("#issdfsdfveTrue").css({
        display: "block"
    });
}

function toancle2() {
    $("#distributor-phone").attr("readonly", "readonly");

    $("#issdfsdfveTrue").css({
        display: "none"
    });
    getOrderDetail();
}

function remaToSave2() {
    $("#distributor-phone").attr("readonly", "readonly");
    $("#issdfsdfveTrue").css({
        display: "none"
    });
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.editTempDeliverInfo,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            express_num: $("#distributor-phone").val()


        }),
        success: function(data) {
            getOrderDetail();
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

//编辑DC
function toassddit3() {
    $("#express_company").removeAttr("readonly");

    $("#issdfssSaveTrue").css({
        display: "block"
    });
}

function toancle3() {
    $("#express_company").attr("readonly", "readonly");

    $("#issdfssSaveTrue").css({
        display: "none"
    });
    getOrderDetail();
}

function remaToSave3() {
    $("#express_company").attr("readonly", "readonly");
    $("#issdfssSaveTrue").css({
        display: "none"
    });
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.editTempDeliverInfo,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            express_num: $("#express_company").val()


        }),
        success: function(data) {
            getOrderDetail();
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

//编辑快递公司
function toassddit4() {
    $("#express_company2").removeAttr("readonly");

    $("#issdfsdfsfsSaveTrue").css({
        display: "block"
    });
}

function toancle4() {
    $("#express_company2").attr("readonly", "readonly");

    $("#issdfsdfsfsSaveTrue").css({
        display: "none"
    });
    getOrderDetail();
}

function remaToSave4() {
    $("#express_company2").attr("readonly", "readonly");
    $("#issdfsdfsfsSaveTrue").css({
        display: "none"
    });
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.editTempDeliverInfo,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            express_company: $("#express_company2").val()


        }),
        success: function(data) {
            getOrderDetail();
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

//编辑快递单号
function toassddit5() {
    $("#express_num").removeAttr("readonly");

    $("#issdfsveTrue").css({
        display: "block"
    });
}

function toancle5() {
    $("#express_num").attr("readonly", "readonly");

    $("#issdfsveTrue").css({
        display: "none"
    });
    getOrderDetail();
}

function remaToSave5() {
    $("#express_num").attr("readonly", "readonly");
    $("#issdfsveTrue").css({
        display: "none"
    });
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.editTempDeliverInfo,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            express_num: $("#express_num").val()


        }),
        success: function(data) {
            getOrderDetail();
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

//编辑实际配送方式
function toassddit6() {
    $("#final_sent").removeAttr("disabled");

    $("#isseTrue").css({
        display: "block"
    });
}

function toancle6() {
    $("#final_sent").attr("disabled", "disabled");

    $("#isseTrue").css({
        display: "none"
    });
    getOrderDetail();
}

function remaToSave6() {
    $("#final_sent").attr("disabled", "disabled");
    $("#isseTrue").css({
        display: "none"
    });
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.editTempDeliverInfo,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            final_sent_type: $("#final_sent").val()


        }),
        success: function(data) {
            getOrderDetail();
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

//编辑快运公司
function toassddit7() {
    $("#express_company3").removeAttr("readonly");

    $("#isfsveTrue").css({
        display: "block"
    });
}

function toancle7() {
    $("#express_company3").attr("readonly", "readonly");

    $("#isfsveTrue").css({
        display: "none"
    });
    getOrderDetail();
}

function remaToSave7() {
    $("#express_company3").attr("readonly", "readonly");
    $("#isfsveTrue").css({
        display: "none"
    });
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.editTempDeliverInfo,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            express_company: $("#express_company3").val()


        }),
        success: function(data) {
            getOrderDetail();
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

//编辑快运单号
function toassddit8() {
    $("#express_num3").removeAttr("readonly");

    $("#isfeTrue").css({
        display: "block"
    });
}

function toancle8() {
    $("#express_num3").attr("readonly", "readonly");

    $("#isfeTrue").css({
        display: "none"
    });
    getOrderDetail();

}

function remaToSave8() {
    $("#express_num3").attr("readonly", "readonly");
    $("#isfeTrue").css({
        display: "none"
    });
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.editTempDeliverInfo,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            express_num: $("#express_num3").val()


        }),
        success: function(data) {
            getOrderDetail();
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

function safdsg() {

    if ($("#final_sent_type option:selected").text() == "快递") {
        if (custormerCode == "D000000025") {
            $("#dddd").css({
                display: "inline"
            });
        } else {
            $("#bbbb").css({
                display: "block"
            });
        }

        $("#bbbb111").css({
            display: "inline"
        });
        $("#aaaa").css({
            display: "none"
        });
        $("#aaaa1").css({
            display: "none"
        });

        $("#aaa111").css({
            display: "none"
        });
        $("#cccc").css({
            display: "none"
        });

        $("#ccc111").css({
            display: "none"
        });
    } else if ($("#final_sent_type option:selected").text() == "快运") {
        if (custormerCode == "D000000025") {
            $("#aaaa1").css({
                display: "inline"
            });
        } else {
            $("#aaaa").css({
                display: "inline"
            });
        }

        $("#aaa111").css({
            display: "inline"
        });
        $("#bbbb").css({
            display: "none"
        });

        $("#dddd").css({
            display: "none"
        });

        $("#bbbb111").css({
            display: "none"
        });
        $("#cccc").css({
            display: "none"
        });

        $("#ccc111").css({
            display: "none"
        });
    } else if ($("#final_sent_type option:selected").text() == "包车专车") {
        $("#cccc").css({
            display: "inline"
        });

        $("#ccc111").css({
            display: "inline"
        });
        $("#bbbb").css({
            display: "none"
        });
        $("#dddd").css({
            display: "none"
        });


        $("#bbbb111").css({
            display: "none"
        });
        $("#aaaa").css({
            display: "none"
        });
        $("#aaaa1").css({
            display: "none"
        });

        $("#aaa111").css({
            display: "none"
        });
    }
}

//再次购买
function zaici() {
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.orderTake,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            orderId: orderId,
            memberId: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
            loginAccount: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name

        }),
        success: function(data) {
            if (data.errorCode == 0) {
                $.Huimodalalert("下推成功！", 2000);
            } else {
                $.Huimodalalert(data.msg, 2000);
            }


        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    });
}

//查看附件
function enclosures() {
    sessionStorage.setItem("orderid", orderId)
    layer_show("查看附件", "Enclosure.html", "800", "600");
}


//确认修改订单价格
function qrxg() {
    var productList = $('#datatable tr');
    var itemsDetail = []
    var skuDetail = {}
    for (var j = 0; j < productList.length; j++) {
        if ($(productList[j]).find('.biaoge1-demolitionOrder_3 input').val() != "" && $(productList[j]).find('.biaoge1-demolitionOrder_3 input').val() != undefined) {
            skuDetail = {
                "skuCode": $(productList[j]).find('#aaaaa').text(), //skuCode
                "updatePrice": $(productList[j]).find('.biaoge1-demolitionOrder_3 input').val(), //修改后价格
            }
            itemsDetail.push(skuDetail)
        }
    }
    $.ajax({
        contentType: "application/json",
        type: "POST",
        url: root.dockingplatform.orderAlterPrice,
        cache: false, //禁用缓存
        dataType: "json",
        data: JSON.stringify({
            orderId: orderId,
            orderItemsDetail: itemsDetail
        }), //传入组装的参数
        success: function(result) {
            if (result.resultCode == '00') {
                layer.msg('修改成功', {
                    icon: 6,
                    time: 1000
                }, function() {
                    var index = parent.location.reload();
                    parent.layer.close(index);
                });
            } else {
                layer.msg(result.resultMessage, {
                    icon: 6,
                    time: 1000
                }, function() {
                    var index = parent.location.reload();
                    parent.layer.close(index);
                });
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest);
        }
    });
}

//通过
function pass() {
    if ($("#orderCategory option:selected").val() == 0) {
        $.Huimodalalert('请编辑订单类别', 2000);
        return false;
    }
    if ($("#warehouseId option:selected").val() == -1) {
        $.Huimodalalert('请编辑发货仓', 2000);
        return false;
    }
    if ($("#secondarysenttype option:selected").val() == -1) {
        $.Huimodalalert('请编辑订单类型', 2000);
        return false;
    }
    if ($("#senttype option:selected").val() == -1) {
        $.Huimodalalert('请编辑配送方式', 2000);
        return false;
    }
    if ($("#qualification_documents").val() == "20") {
        redReal = "0"
    } else {
        redReal = $("input[name=qiding]:checked").val()
    }
    console.log("parent______" + sessionStorage.getItem("parent_customer_code"));
    if (sessionStorage.getItem("parent_customer_code") == "DJ00000007" || sessionStorage.getItem("parent_customer_code") == "D000000028" || sessionStorage.getItem("parent_customer_code") == 'D000000031' || sessionStorage.getItem("parent_customer_code") == 'D000000030' || sessionStorage.getItem("parent_customer_code") == "D000000035"|| sessionStorage.getItem("parent_customer_code") == "D000000041"|| sessionStorage.getItem("parent_customer_code") == "D000000034"|| sessionStorage.getItem("parent_customer_code") == "D000000033"|| sessionStorage.getItem("parent_customer_code") == "D000000040") {
        console.log('jiangong')
        var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
        var secondary_sent_type = changies(orderDetail.orderExt.sent_type)
        if (orderDetail.modify_may_arrived == 0) {

            layer.confirm('确认该订单为正常订单？该订单配送方式是' + secondary_sent_type + '', function(index) {
                if (ordertype.match('50')) {
                    updamm()
                } else {
                    var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
                    $.ajax({
                        contentType: "application/json",
                        type: "POST",
                        url: root.dockingplatform.approvalChannelPreOrder,
                        cache: false, //禁用缓存
                        dataType: "json",
                        data: JSON.stringify({
                            "orderId": orderId,
                            operatorId: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                            operatorName: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
                            operatorCode: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.number,
                            isNeedQualification: $("#qualification_documents").val(),
                            qualificationRedSeal: redReal ? redReal : 0, // qualificationRedSeal不能为空，如果获取的值是空，就默认为0
                            // qualificationNumber:  $("#qualification_number").val() ? $("#qualification_number").val() : 0, // qualificationNumber不能为空，如果获取的值是空，就默认为0
                            qualificationNumber: 0,
                            orderBigType: $("#orderCategory option:selected").val()

                        }), //传入组装的参数
                        success: function(result) {
                            if (result.errorCode == 0) {
                                layer.msg('已通过', {
                                    icon: 6,
                                    time: 1000
                                }, function() {
                                    var index = parent.location.reload();
                                    parent.layer.close(index);
                                });
                            } else {
                                layer.msg(result.msg, {
                                    icon: 6,
                                    time: 1000
                                }, function() {
                                    var index = parent.location.reload();
                                    parent.layer.close(index);
                                });
                            }

                        },
                        error: function(XMLHttpRequest, textStatus, errorThrown) {
                            alert(XMLHttpRequest);
                        }
                    });
                }

            });
        } else {
            layer.confirm('确认该订单为正常订单？该订单配送方式是' + secondary_sent_type + '<br>预计送达时间已修改，请确认是否正确', function(index) {
                $.ajax({
                    contentType: "application/json",
                    type: "POST",
                    url: root.dockingplatform.approvalChannelPreOrder,
                    cache: false, //禁用缓存
                    dataType: "json",
                    data: JSON.stringify({
                        "orderId": orderId,
                        operatorId: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                        operatorName: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
                        operatorCode: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.number,
                        isNeedQualification: $("#qualification_documents").val(),
                        // qualificationRedSeal: redReal,
                        // qualificationNumber: $("#qualification_number").val(),
                        qualificationRedSeal: redReal ? redReal : 0, // qualificationRedSeal不能为空，如果获取的值是空，就默认为0
                        qualificationNumber: $("#qualification_number").val() ? $("#qualification_number").val() : 0, // qualificationNumber不能为空，如果获取的值是空，就默认为0
                        orderBigType: $("#orderCategory option:selected").val()
                    }), //传入组装的参数
                    success: function(result) {
                        if (result.errorCode == 0) {
                            layer.msg('已通过', {
                                icon: 6,
                                time: 1000
                            }, function() {
                                var index = parent.location.reload();
                                parent.layer.close(index);
                            });
                        } else {
                            layer.msg(result.msg, {
                                icon: 6,
                                time: 1000
                            }, function() {
                                var index = parent.location.reload();
                                parent.layer.close(index);
                            });
                        }
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest);
                    }
                });
                layer.msg('已审核', {
                    icon: 6,
                    time: 1000
                });

            });
        }
    } else {
        console.log('other')
        var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
        var secondary_sent_type = changies(orderDetail.orderExt.sent_type)
        if (orderDetail.modify_may_arrived == 0) {


            layer.confirm('确认该订单为正常订单？该订单配送方式是' + secondary_sent_type + '', function(index) {
                if (ordertype.match('50')) {
                    updamm()
                } else {
                    var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
                    $.ajax({
                        contentType: "application/json",
                        type: "POST",
                        url: root.dockingplatform.approvalPreOrder,
                        cache: false, //禁用缓存
                        dataType: "json",
                        data: JSON.stringify({
                            "orderId": orderId,
                            operatorId: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                            operatorName: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
                            channelOrderId: orderDetail.channel_order_id,
                            operatorCode: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.number,
                            isNeedQualification: $("#qualification_documents").val(),
                            // qualificationRedSeal: $("input[name=qiding]:checked").val(),
                            // qualificationNumber: $("#qualification_number").val(),
                            qualificationRedSeal: $("input[name=qiding]:checked").val() ? $("input[name=qiding]:checked").val() : 0, // qualificationRedSeal不能为空，如果获取的值是空，就默认为0
                            qualificationNumber: $("#qualification_number").val() ? $("#qualification_number").val() : 0, // qualificationNumber不能为空，如果获取的值是空，就默认为0
                            orderBigType: $("#orderCategory option:selected").val()
                        }), //传入组装的参数
                        success: function(result) {
                            if (result.errorCode == 0) {
                                layer.msg('已通过', {
                                    icon: 6,
                                    time: 1000
                                }, function() {
                                    var index = parent.location.reload();
                                    parent.layer.close(index);
                                });
                            } else {
                                layer.msg(result.msg, {
                                    icon: 6,
                                    time: 1000
                                }, function() {
                                    var index = parent.location.reload();
                                    parent.layer.close(index);
                                });
                            }

                        },
                        error: function(XMLHttpRequest, textStatus, errorThrown) {
                            alert(XMLHttpRequest);
                        }
                    });
                    layer.msg('已审核', {
                        icon: 6,
                        time: 1000
                    });
                }

            });
        } else {
            layer.confirm('确认该订单为正常订单？该订单配送方式是' + secondary_sent_type + '<br>预计送达时间已修改，请确认是否正确', function(index) {
                $.ajax({
                    contentType: "application/json",
                    type: "POST",
                    url: root.dockingplatform.approvalPreOrder,
                    cache: false, //禁用缓存
                    dataType: "json",
                    data: JSON.stringify({
                        "orderId": orderId,
                        operatorId: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                        operatorName: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
                        channelOrderId: orderDetail.channel_order_id,
                        operatorCode: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.number,
                        isNeedQualification: $("#qualification_documents").val(),
                        // qualificationRedSeal: $("input[name=qiding]:checked").val(),
                        // qualificationNumber: $("#qualification_number").val(),
                        qualificationRedSeal: $("input[name=qiding]:checked").val() ? $("input[name=qiding]:checked").val() : 0, // qualificationRedSeal不能为空，如果获取的值是空，就默认为0
                        qualificationNumber: $("#qualification_number").val() ? $("#qualification_number").val() : 0, // qualificationNumber不能为空，如果获取的值是空，就默认为0
                        orderBigType: $("#orderCategory option:selected").val()
                    }), //传入组装的参数
                    success: function(result) {
                        if (result.errorCode == 0) {
                            layer.msg('已通过', {
                                icon: 6,
                                time: 1000
                            }, function() {
                                var index = parent.location.reload();
                                parent.layer.close(index);
                            });
                        } else {
                            layer.msg(result.msg, {
                                icon: 6,
                                time: 1000
                            }, function() {
                                var index = parent.location.reload();
                                parent.layer.close(index);
                            });
                        }
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest);
                    }
                });
                layer.msg('已审核', {
                    icon: 6,
                    time: 1000
                });

            });
        }
    }


}

function changies(secondarysenttype) {

    switch (secondarysenttype) {
        /*配送方式*/
        case 10:
            return "快递";
            break;
        case 20:
            return "快运";
            break;
        case 30:
            return "专车包车";
            break;
        case 40:
            return "鑫方盛物流";
            break;

    }


}

//修改密码
var index = 0;

function updamm() {
    var cu = layer.confirm('<span>存在低于成本价的商品，确认通过？</span><input class="input-text radius" placeholder="请输入密码" type="password" style="padding-left: 10px;" id="remarksr">', {
        title: '提示',
        btn: ['确认', '取消']
    }, function(index) {
        fini3();
        layer.close(cu);
    }, function() {
        layer.close(cu);

    });
}

//第二个
function fini3() {

    if ($("#qualification_documents").val() == "20") {
        redReal = "0"
    } else {
        redReal = $("input[name=qiding]:checked").val()
    }

    if (sessionStorage.getItem("parent_customer_code") == "DJ00000007") {
        var remarksr = $("#remarksr").val();
        console.log(remarksr)
        var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
        $.ajax({
            url: root.orderInter.checkPriceRevisionPwd,
            cache: false, //禁用缓存
            type: "POST",
            dataType: 'json',
            async: false,
            data: {
                password: $("#remarksr").val().trim()
            },
            success: function(data) {
                if (data.data == 10) {
                    $.ajax({
                        contentType: "application/json",
                        type: "POST",
                        url: root.dockingplatform.approvalChannelPreOrder,
                        cache: false, //禁用缓存
                        dataType: "json",
                        data: JSON.stringify({
                            "orderId": orderId,
                            operatorId: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                            operatorName: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
                            operatorCode: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.number,
                            isNeedQualification: $("#qualification_documents").val(),
                            // qualificationRedSeal: redReal,
                            // qualificationNumber: $("#qualification_number").val()
                            qualificationRedSeal: redReal ? redReal : 0, // qualificationRedSeal不能为空，如果获取的值是空，就默认为0
                            qualificationNumber: $("#qualification_number").val() ? $("#qualification_number").val() : 0, // qualificationNumber不能为空，如果获取的值是空，就默认为0
                        }), //传入组装的参数
                        success: function(result) {
                            layer.msg('已通过', {
                                icon: 6,
                                time: 1000
                            }, function() {
                                var index = parent.location.reload();
                                parent.layer.close(index);
                            });
                        },
                        error: function(XMLHttpRequest, textStatus, errorThrown) {
                            alert(XMLHttpRequest);
                        }
                    });
                    layer.msg('已审核', {
                        icon: 6,
                        time: 1000
                    });
                } else {
                    $.Huimodalalert(data.sub_msg, 2000);
                }


            },
            error: function() {
                $.Huimodalalert('失败！', 2000);
            }
        })
        layer.close(index);
    } else {
        var remarksr = $("#remarksr").val();
        console.log(remarksr)
        var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
        $.ajax({
            url: root.orderInter.checkPriceRevisionPwd,
            cache: false, //禁用缓存
            type: "POST",
            dataType: 'json',
            async: false,
            data: {
                password: $("#remarksr").val().trim()
            },
            success: function(data) {
                if (data.data == 10) {
                    $.ajax({
                        contentType: "application/json",
                        type: "POST",
                        url: root.dockingplatform.approvalPreOrder,
                        cache: false, //禁用缓存
                        dataType: "json",
                        data: JSON.stringify({
                            "orderId": orderId,
                            operatorId: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                            operatorName: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
                            channelOrderId: orderDetail.channel_order_id,
                            operatorCode: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.number,
                            isNeedQualification: $("#qualification_documents").val(),
                            // qualificationRedSeal: $("input[name=qiding]:checked").val(),
                            // qualificationNumber: $("#qualification_number").val(),
                            qualificationRedSeal: $("input[name=qiding]:checked").val() ? $("input[name=qiding]:checked").val() : 0, // qualificationRedSeal不能为空，如果获取的值是空，就默认为0
                            qualificationNumber: $("#qualification_number").val() ? $("#qualification_number").val() : 0, // qualificationNumber不能为空，如果获取的值是空，就默认为0
                            orderBigType: $("#orderCategory option:selected").val()
                        }), //传入组装的参数
                        success: function(result) {
                            layer.msg('已通过', {
                                icon: 6,
                                time: 1000
                            }, function() {
                                var index = parent.location.reload();
                                parent.layer.close(index);
                            });
                        },
                        error: function(XMLHttpRequest, textStatus, errorThrown) {
                            alert(XMLHttpRequest);
                        }
                    });
                    layer.msg('已审核', {
                        icon: 6,
                        time: 1000
                    });
                } else {
                    $.Huimodalalert(data.sub_msg, 2000);
                }


            },
            error: function() {
                $.Huimodalalert('失败！', 2000);
            }
        })
        layer.close(index);
    }


}

//修改预计送达时间
function estimate() {
    sessionStorage.setItem("orderIds", orderId);
    sessionStorage.setItem("wuliu", wuliu);
    layer_show("修改时间", "estimate.html", "800", "500");
}

//修改配送方式
function delivery() {
    $("#da").css({
        display: "none"
    });
    $("#db").css({
        display: "inline"
    });
    $("#finalent").css({
        display: "inline"
    });
    $("#dc").css({
        display: "inline"
    });
    if (wuliu == 40) {
        $("#b").css({
            display: "none"
        });
        $("#c").css({
            display: "none"
        });
    }

}

function delivery3() {
    $("#da").css({
        display: "inline"
    });
    $("#db").css({
        display: "none"
    });
    $("#finalent").css({
        display: "none"
    });
    $("#dc").css({
        display: "none"
    });
}

function delivery2() {
    $.ajax({
        contentType: "application/json",
        type: "POST",
        url: root.dockingplatform.updatePreOrder,
        cache: false, //禁用缓存
        dataType: "json",
        data: JSON.stringify({
            "orderId": orderId,
            "mayArrivedIn": "",
            "sentType": $("#finalent").val(),
            "actualShippingFee": "",
            "secondarySentType": "",
            "operateUserId": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
            "operateUserName": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
        }),
        success: function(result) {
            if (result.errorCode == 0) {
                $("#da").css({
                    display: "inline"
                });
                $("#db").css({
                    display: "none"
                });
                $("#finalent").css({
                    display: "none"
                });
                $("#dc").css({
                    display: "none"
                });
                getOrderDetail();
            } else {
                $.Huimodalalert(result.msg, 2000);
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest);
        }
    });
}

function couponre() {
    $("#ca").css({
        display: "none"
    });
    $("#cb").css({
        display: "inline"
    });
    $("#cy").css({
        display: "inline"
    });
    $("#cc").css({
        display: "inline"
    });
    $("#cf").css({
        display: "inline"
    });

}

function couponre3() {
    $("#ca").css({
        display: "inline"
    });
    $("#cb").css({
        display: "none"
    });
    $("#cy").css({
        display: "none"
    });
    $("#cc").css({
        display: "none"
    });
    $("#cf").css({
        display: "none"
    });
}

function couponre2() {
    $.ajax({
        contentType: "application/json",
        type: "POST",
        url: root.dockingplatform.updatePreOrder,
        cache: false, //禁用缓存
        dataType: "json",
        data: JSON.stringify({
            "orderId": orderId,
            "mayArrivedIn": "",
            "sentType": $("#senttype option:selected").val(),
            "actualShippingFee": $("#cy").val(),
            "secondarySentType": $("#secondarysenttype option:selected").val(),
            "operateUserId": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
            "operateUserName": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
        }),
        success: function(result) {
            if (result.errorCode == 0) {
                $("#ca").css({
                    display: "inline"
                });
                $("#cb").css({
                    display: "none"
                });
                $("#cy").css({
                    display: "none"
                });
                $("#cc").css({
                    display: "none"
                });
                $("#cf").css({
                    display: "none"
                });
                getOrderDetail();
            } else {
                $.Huimodalalert(result.msg, 2000);
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest);
        }
    });
}

//确认收货
function receiving() {
    var cu = layer.confirm('<span>确定确认收货吗？</span>', { title: '提示', btn: ['确认', '取消'] }, function(index) {
        receiving2()
        layer.close(cu);
    }, function() {
        layer.close(cu);

    });
}

function receiving2() {
    $.ajax({
        contentType: "application/json",
        type: "POST",
        url: 'https://' + window.location.host + '/api/admin/aorder/platform/preConfirmReceipt',
        cache: false, //禁用缓存
        dataType: "json",
        data: JSON.stringify({
            order_id: orderId,
            member_id: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
            login_account: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
        }),
        success: function(result) {
            console.log(result)
            if (result.errorCode == 0) {
                $.Huimodalalert("确认收货成功", 2000);
                location.replace(location.href);
            } else {
                $.Huimodalalert(result.msg, 2000);
            }


        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            layer.msg('请求失败，请刷新后重试！');
            isIng = false;
        }
    });
}


//操作日志
function operationlog() {
    sessionStorage.setItem("orderIds", orderId);
    sessionStorage.setItem("status", sessionStorage.getItem("orderStatus"));
    var title = "操作日志"
    var url = "operationLog.html"
    var index = layer.open({
        type: 2,
        title: title,
        content: url
    });
    layer.full(index);
}

//厂家直送-----配送方式 点击编辑
function toEsdzxcdit2() {
    // $("#final_sent").empty();
    $("#final_sent_type1").removeAttr("disabled");
    // $("#final_sent").removeAttr("disabled");
    $("#issdfsSaveTrue").css({
        display: "inline"
    })

}


//编辑厂家直达-----点击保存
function remarkToSave2() {

    $("#final_sent_type1").attr("disabled", "disabled");
    // $("#final_sent").attr("disabled", "disabled");
    $("#issdfsSaveTrue").css({
            display: "none"
        })
        // var finalsent_type='';
        // if (result11.data.orderBase.order_status==20 && result11.data.exception_type.match(120)){
    var finalsent_type = $("#final_sent_type1").val()
        // }
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        // url:root.orderInter.updateSecondarySentType,
        // url:root.dockingplatform.updatePreOrder,
        url: root.dockingplatform.updatePreOrder,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            "orderId": orderId,
            "secondarySentType": finalsent_type,
            "mayArrivedIn": "",
            "sentType": "",
            "actualShippingFee": "",
            "operateUserId": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
            "operateUserName": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name
        }),
        success: function(data) {
            location.replace(location.href);
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

//厂家直送----点击取消
function toCancle2() {
    console.log("aaa");
    $("#final_sent_type1").attr("disabled", "disabled");
    $("#final_sent1").attr("disabled", "disabled");
    $("#issdfsSaveTrue").css({
            display: "none"
        })
        // getOrdertail();
        // getOrderDetail();
    $("#final_sent_type1").val(result11.data.orderExt.secondary_sent_type);
    // location.replace(location.href);
}

//拆单
function demolitionOrder() {
    if ($("#orderCategory option:selected").val() == 0) {
        $.Huimodalalert('请编辑订单类别', 2000);
        return false;
    }
    if ($("#warehouseId option:selected").val() == -1) {
        $.Huimodalalert('请编辑发货仓', 2000);
        return false;
    }
    if ($("#secondarysenttype option:selected").val() == -1) {
        $.Huimodalalert('请编辑订单类型', 2000);
        return false;
    }
    if ($("#senttype option:selected").val() == -1) {
        $.Huimodalalert('请编辑配送方式', 2000);
        return false;
    }
    if (orderSplitStatus == 0) {
        var curInd = layer.confirm(
            '<span>确认是否拆单？</span>' + '<br/>', { title: '提示', btn: ['确定', '取消'] },
            function(index) {
                /*     $.ajax({
                         url:root.sroreinter.deleteLinkConfig,
                         cache: false,  //禁用缓存
                         type: "POST",
                         dataType:'json',
                         contentType: "application/json",
                         data: JSON.stringify({
                             "id":id,
                             "operatorId":JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                             "operatorName":JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
                         }),
                         success: function (data) {
                             if(data.code==0){
                                 $.Huimodalalert('删除成功',2000);
                                 toConfigure()

                             }else {

                                 $.Huimodalalert(data.msg,2000);

                             }
                         },
                         error: function () {
                             $.Huimodalalert('失败！',2000);
                         }
                     })*/

                sessionStorage.setItem("demolitionOrderId", orderId);
                var title = "拆单";
                var url = "demolitionOrder.html";
                var index = layer.open({
                    type: 2,
                    title: title,
                    content: url,
                    end: function() {
                        location.replace(location.href)
                    }
                });
                layer.full(index);

                layer.close(curInd);

            },
            function() {
                layer.close(curInd);

            });
    } else {
        sessionStorage.setItem("demolitionOrderId", orderId);
        var title = "拆单";
        var url = "demolitionOrder.html";
        var index = layer.open({
            type: 2,
            title: title,
            content: url
        });
        layer.full(index);

        layer.close(curInd);
    }
}

//上传凭证
function uploadProof() {
    layer_show("添加图片", "skuPic.html", "1200", "700", "100", "200");
}

//查看凭证
function checkProof() {
    layer_show("查看图片", "imgManage.html", "1200", "700", "100", "200");
}

//
function updataLngLat() {
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        // url:root.orderInter.updateSecondarySentType,
        // url:root.dockingplatform.updatePreOrder,
        url: root.dockingplatform.queryLonAndLat,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            "orderId": orderId
        }),
        success: function(data) {
            location.replace(location.href);
        },
        error: function() {
            $.Huimodalalert('经纬度为空，请重新获取！', 2000);
        }
    })
}

//重新生成经纬度
function rebuilds() {
    $.ajax({
        url: root.dockingplatform.queryLonAndLat,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: {
            "orderId": orderId,
            // "operate_userid":JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
            // "operate_username":JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
        },
        success: function(data) {
            if (data.errorCode == 0) {

                $.Huimodalalert("经纬度已生成", 2000);
                getOrderDetail()

            } else {
                $.Huimodalalert(data.msg, 2000);

            }
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })
}

function gradeChange() {
    var objS = document.getElementById("qualification_documents");
    var grade = objS.options[objS.selectedIndex].value;
    if (grade == 10) {
        $("#is_qualification").attr("checked", "checked");
        $("#qualification").css({
            display: "inline"
        });
    } else {
        $("#qualification").css({
            display: "none"
        });
        /*$("#is_qualification").val("");
        $("#no_qualification").val("");*/

        $("#qualification_number").val("0");
        $("input[name=qiding]:checked").val("0")
    }
}


//下推订单
function pushOrder() {
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.pushOrder,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            operator_id: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
            operator_name: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name

        }),
        success: function(data) {
            if (data.errorCode == 0) {
                layer.msg("订单已加入下推列队，成功与否请稍后查看", { icon: 6, time: 1000 }, function() {
                    pushOrdererrorCode = 0
                    location.replace(location.href)
                });
            } else {
                layer.msg(data.msg, { icon: 5, time: 1000 }, function() {
                    pushOrdererrorCode = 1
                    location.replace(location.href)
                });
            }
        },
        error: function() {
            $.Huimodalalert('请重新下推！', 2000);
        }
    });
}


//下推订单结果
function pushOrder2() {
    $("#pushOrderinformation").modal("show");
    if (pushOrdererrorCode == 1) {
        $("#nos").css({
            display: "inline"
        });
        $("#reasons").html(JSON.parse(sessionStorage.getItem("orderDetail")).push_message)
    } else {
        $("#nos").css({
            display: "none"
        });
        $("#reasons").html("订单已加入下推列队，成功与否请稍后查看")
    }

}

//刷新库存
function refreshStock(val) {
    var itemsDetail = [];
    var skuDetail = {};
    skuDetail = {
        "skuCode": "1245", //skuCode
        "skuNum": 5, //skuNum

    }
    itemsDetail.push(skuDetail)


    $.ajax({
        type: "POST",
        url: root.dockingplatform.refreshActoActualStock,
        cache: false, //禁用缓存
        dataType: "json",
        contentType: "application/json;charset=UTF-8",

        data: JSON.stringify({
            orderId: orderId,
            // "mayArrivedIn":$("#logmin").val(),
            operateUserId: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
            operateUserName: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
            orderItemsDetail: itemsDetail
        }),
        success: function(result) {
            if (result.errorCode == 0) {

                /*var tablesall=$('.shun').children().children()[4]
                for (var j = 0; j < result.data.length; j++) {
                    $(tablesall).find("#create_time").html(result.data[j].actualStock)
                }*/

                var productList = $('.shun').find('.biaoge1-6');
                for (var j = 0; j < result.data.length; j++) {
                    $(productList[j]).text(result.data[j].actualStock)
                }

                if (val == 2) {
                    $.Huimodalalert("刷新成功", 2000);
                }

            } else {
                $.Huimodalalert(result.msg, 2000);
            }
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })

}
var warehouseIdssss = ""
var isBiddingdata = false;

function QueryorderDetail(results) {
    if (results.data.isBidding == 1) { // 是竞价订单
        isBiddingdata = true
        $(".order-isBidding").css({ display: 'inline' })
        $("#pass").css({ display: 'inline' })
        $("#projectName").html(results.data.projectName)
        $("#projectCode").html(results.data.projectCode)
            // $("#budgetMoney").html(results.data.budgetMoney)
        if (isBiddingdata) {
            channelPrduct = "<th style=\"width: 300px;\">渠道商品信息</th>"
        }
    }
    $("#datatable").html("<thead>\n" +
        "                    <tr >\n" + channelPrduct +
        "                        <th style=\"width: 300px;\">商品</th>\n" +
        "                        <th>商品类型</th>\n" +
        "                        <th>购买数量</th>\n" +
        "                        <th>可用库存</th>\n" +
        "                        <th>超卖数量</th>\n" +
        "                        <th>出库数量</th>\n" +
        "                        <th>收货数量</th>\n" +
        "                        <th>退货数量</th>\n" +
        "                        <th style=\"width:200px;\">对方结算价</th>\n" +
        "                        <th style=\"width:200px;\">修改结算价</th>\n" +
        "                        <th style=\"width:200px;\">我方结算价</th>\n" +
        "                        <th>运费分摊</th>\n" +
        "                        <th>小计</th>\n" +
        "                    </tr>\n" +
        "                    </thead>\n" +
        "                    <tbody class=\"shun\">\n" +
        "                    </tbody>");
    //分单按钮展示
    if (results.data.assignButton == true && results.data.isBidding != 1) {
        $("#reinsurancepolicy").css({
            display: "inline"
        })
    } else {
        $("#reinsurancepolicy").css({
            display: "none"
        })
    }

    var $newCustomerName = $('#form-member-add .new-customer-name #editCustomerBtn');
    if (results && results.data && results.data.orderBase && results.data.orderBase.order_status == 20) {
        $newCustomerName.show();
    } else {
        $newCustomerName.hide();
    }
    //渠道信息表维护是否客户签收，是则订单待收货状态，订单详情页展示签收状态，初始状态为未签收；否则不展示签收状态字段
    if (results.data.channelConfig != "" && results.data.channelConfig != null) {
        if (results.data.channelConfig.customerSigningSupport == 0) {
            $("#customerSigningSupport").css({
                display: "none"
            })
        } else if (results.data.channelConfig.customerSigningSupport == 1) {
            $("#customerSigningSupport").css({
                display: "inline"
            })
        }
    }
    //订单类别
    $("#orderCategory").val(results.data.orderExt.order_big_type)
        //发货仓
    if (results.data.orderBase.warehouse_id != -1) {
        $("#warehouseId option:selected").val(results.data.orderBase.warehouse_id)
        var warehouseName = ''
        $.each(warehouses.data, function(k, s) {
            if (results.data.orderBase.warehouse_id == s.warehouseCode) {
                warehouseName = s.warehouseName
            }
        })
        $("#warehouseId option:selected ").html(warehouseName)
        $("#warehouseId option:selected").attr("disabled", "disabled")
    } else {
        $("#warehouseId option:selected").val(results.data.orderBase.warehouse_id)
        $("#warehouseId option:selected").html("请选择")
    }

    //订单类型
    if(results.data.orderExt.common_order_type){
        $("#secondarysenttype option:selected").val(results.data.orderExt.common_order_type)
        var secondarysenttypename=""
        if(results.data.orderExt.common_order_type== 19649){
            secondarysenttypename="配送订单"
        }else if(results.data.orderExt.common_order_type== 19653){
            secondarysenttypename="厂家直送"
        }else if(results.data.orderExt.common_order_type== 19652){
            secondarysenttypename="专线订单"
        }else if(results.data.orderExt.common_order_type== 19650){
            secondarysenttypename="外阜订单"
        }
        $("#secondarysenttype option:selected").html(secondarysenttypename)
        $("#secondarysenttype option:selected").attr("disabled","disabled")
    }else {
        $("#secondarysenttype option:selected").val(-1)
        $("#secondarysenttype option:selected").html("请选择")
    }

    //配送方式
    if (results.data.orderExt.sent_type != -1) {
        $("#senttype option:selected").val(results.data.orderExt.sent_type)
        var senttypename = ""
        if (results.data.orderExt.sent_type == 10) {
            senttypename = "快递"
        } else if (results.data.orderExt.sent_type == 20) {
            senttypename = "快运-送货上门"
        } else if (results.data.orderExt.sent_type == 21) {
            senttypename = "快运-站点自提"
        } else if (results.data.orderExt.sent_type == 30) {
            senttypename = "专车包车"
        } else if (results.data.orderExt.sent_type == 40) {
            senttypename = "鑫方盛物流"
        } else if (results.data.orderExt.sent_type == 50) {
            senttypename = "上门自提"
        }
        $("#senttype option:selected").html(senttypename)
        $("#senttype option:selected").attr("disabled", "disabled")
    } else {
        $("#senttype option:selected").val(results.data.orderExt.sent_type)
        $("#senttype option:selected").html("请选择")
    }





    var channelSigningStatus = ""
    if (results.data.channelSigningStatus == 0) {
        channelSigningStatus = '未签收'
    } else if (results.data.channelSigningStatus == 1) {
        channelSigningStatus = '已签收'
    }
    $("#channelSigningStatus").html(channelSigningStatus)
    result11 = results;
    //收货人信息
    var listAddressReceiverarr = []
    var listAddressReceivers = ""
    if (results.data.listAddressReceiver != "" || results.data.listAddressReceiver != null) {

        var listAddressReceiverall = results.data.listAddressReceiver
        for (var k = 0; k < listAddressReceiverall.length; k++) {

            var information = listAddressReceiverall[k].receiver_name + '&nbsp' + listAddressReceiverall[k].mobile;
            listAddressReceiverarr.push(information);
        }
        for (var j = 0; j < listAddressReceiverarr.length; j++) {
            if (j < listAddressReceiverarr.length - 1) {
                listAddressReceivers += listAddressReceiverarr[j] + "、";
            } else {
                listAddressReceivers += listAddressReceiverarr[j] + "";
            }
        }
        sessionStorage.setItem("listAddressReceivers", listAddressReceivers)
            // $("#listAddressReceiver").html(listAddressReceivers)

    }
    var oop = ""
    if (results.data.orderExt.lat == "" && results.data.orderExt.lat == null) {
        oop = results.data.orderExt.lng
    } else if (results.data.orderExt.lng == "" && results.data.orderExt.lng == null) {
        oop = results.data.orderExt.lat
    } else if (results.data.orderExt.lng == "" || results.data.orderExt.lng == null && results.data.orderExt.lat == "" || results.data.orderExt.lat == null) {
        oop = ""
    } else {
        oop = results.data.orderExt.lng + ',' + results.data.orderExt.lat
        $("#rebuilds").attr("style", "color:#aaaaaa")
        $("#rebuilds").attr("onclick", "") //置灰*/
    }
    $("#lng").html(oop);


    /*if (result11.data.orderBase.order_status == 9 || result11.data.orderBase.order_status == 10 || result11.data.orderBase.order_status == 20 || result11.data.orderBase.order_status == 30 || result11.data.orderBase.order_status == 40 || result11.data.orderBase.order_status == 50) {

        $("#final_sent option:selected").val("")
    } else {*/
    console.log("状态：" + results.data.orderBase.order_status);
    // }
    console.log("状态：" + results.data.orderBase.order_status);
    if (results.data.orderBase.order_status == 40 && results.data.orderExt.common_order_type == 19653 && results.data.cancle_apply_show == true) {
        $("#frglivergoods").css({
            display: "inline"
        });
    }
    sessionStorage.setItem("parent_customer_code", results.data.parent_customer_code);

    sessionStorage.setItem("parent_warehouse_id", results.data.orderBase.parent_warehouse_id);

    sessionStorage.setItem("parent_customer_code", results.data.parent_customer_code);
    custormerCode = results.data.parent_customer_code;
    //拆单按钮控制
    /*if(results.data.orderBase.order_status==20 && results.data.orderBase.parent_order_id=='' && results.data.orderBase.order_split_status!=20 && results.data.exception_type.match(40) && (results.data.parent_customer_code=="11.11.11110" || results.data.parent_customer_code=="01.01.0533") ){
        $("#demolitionOrder").css({
            display: "inline"
        });
    }*/


    /*超卖商品*/
    var chaomai = 0;
    if (results.data.normalPricePreOrderItemsList != "" && results.data.normalPricePreOrderItemsList != null) {
        var arr = results.data.normalPricePreOrderItemsList;
        $.each(arr, function(k, v) {
            if (v.occupy_virtual_store == 0) {
                chaomai = 1; //含有现货商品
            }
        })
    }

    console.log("chaomai", chaomai)

    if (results.data.orderBase.order_status == 20 && results.data.exception_type.match(40) && chaomai == 0) {

        $("#sent_type").css({
            display: "inline"
        });

        $("#isSavsdfsfsdeFalse").css({
            display: "inline"
        });
    }

    /*临采商品*/
    //fahuo!="a"

    var fa = 0;
    if (results.data.normalPricePreOrderItemsList != "" && results.data.normalPricePreOrderItemsList != null) {
        var arr = results.data.normalPricePreOrderItemsList;
        $.each(arr, function(k, v) {
            if (v.is_temp_sku == 20) { //正常商品
                fa = 1;
            }
        })
    }
    console.log("fa", fa);
    if (results.data.orderBase.order_status == 20 && results.data.exception_type.match(120) && fa == 0) {
        $("#sent_type").css({
            display: "inline"
        });

        $("#isSavsdfsfsdeFalse").css({
            display: "inline"
        });
    }
    /*服务商商品*/
    if (results.data.orderBase.order_status == 20 && results.data.exception_type.match(160) && chaomai == 0) {
        $("#sent_type").css({
            display: "inline"
        });

        $("#isSavsdfsfsdeFalse").css({
            display: "inline"
        });
    }

    sessionStorage.setItem("orderStatus", results.data.orderBase.order_status);
    var result = results.data;
    console.log(2123);
    wuliu = result.orderExt.sent_type
    if (result.listOrderAttachment != "" && result.listOrderAttachment != null) {
        $("#enclosure").css({
            display: "block"
        });
    }

    if (result.listOrderAttachment != "" && result.listOrderAttachment != null) {
        $("#enclosure").css({
            display: "block"
        });
    }

    ordertype = result.exception_type;
    sessionStorage.removeItem("Identification");
    if (result.listOrderRefund != null && result.listOrderRefund != '') {
        $("#returnInfoBox").css({
            display: "block"
        });
    } else {
        $("#returnInfoBox").css({
            display: "none"
        });
    }

    //询价单号展示
    if (result.inquiry_num != '' && result.orderExt.order_type == 20) {
        $("#inquiry").css({
            display: "inline"
        });
    }
    //优惠劵，运费卷展示
    if (result.orderCoupon != "" && result.orderCoupon != null) {
        if (result.orderCoupon.coupon_type == 10) {
            $("#couponInfo11").css({
                display: "inline"
            });
        } else {
            $("#couponInfsfo11").css({
                display: "inline"
            });
        }
    }
    //上门自提
    if (result.orderExt.sent_type == 50) {
        $("#selftakein").css({
            display: "block"
        });
        $("#selftakeshop").css({
            display: "block"
        });
        $("#receiverdetailaddress").css({
            display: "block"
        });
        $("#selftakephone").css({
            display: "block"
        });
        $("#wanna_edin").css({
            display: "none"
        });
        $("#predixttime").css({
            display: "none"
        });
    } else {
        $("#selftakein").css({
            display: "none"
        });
        $("#selftakeshop").css({
            display: "none"
        });
        $("#receiverdetailaddress").css({
            display: "none"
        });
        $("#selftakephone").css({
            display: "none"
        });
        $("#wanna_edin").css({
            display: "block"
        });
        $("#predixttime").css({
            display: "block"
        });
    }
    if (result.orderWarning != null && result.orderWarning.warning_status == 20) {
        $("#relieverole").css({
            display: "block"
        });
        $("#operatedat").css({
            display: "block"
        });
    }

    //发票类型展示
    if (result.orderInvoice != null) {
        if (result.orderInvoice.invoice_type == 20 && result.orderInvoice.invoice_title == '个人') {

            $("#invoice-type1").show();
            $("#invoice_t").css({
                display: "none"
            });
            $("#taxpayer_identify_num1").css({
                display: "none"
            });
            $("#register_address1").hide()
            $("#register_phone1").hide()
            $("#open_bank1").hide()
            $("#bank_account1").hide()

        } else {
            $("#invoice-type1").show()
            $("#invoice_t").css({
                display: "inline"
            });
            $("#taxpayer_identify_num1").css({
                display: "inline"
            });
            $("#register_address1").hide();
            $("#register_phone1").hide();
            $("#open_bank1").hide();
            $("#bank_account1").hide()

        }

        if (result.orderInvoice.invoice_type == 10) {
            $("#invoice-type1").show()
            $("#invoice_t").css({
                display: "inline"
            });
            $("#taxpayer_identify_num1").css({
                display: "inline"
            });
            $("#register_address1").show()
            $("#register_phone1").show()
            $("#open_bank1").show()
            $("#bank_account1").show()
        }
    } else {
        $("#invoice-type1").show()
        $("#invoice_t").css({
            display: "none"
        });
        $("#taxpayer_identify_num1").css({
            display: "none"
        });
        $("#register_address1").hide()
        $("#register_phone1").hide()
        $("#open_bank1").hide()
        $("#bank_account1").hide()
    }


    if (result.orderExt != null && result.orderExt.platform == 10) {
        $("#alsi").hide();
        $("#alisaAddress").hide();
    } else {
        $("#alsi").show();
        $("#alisaAddress").show();

    }
    if (result.orderExt != null && result.orderExt.platform == 10 || result.orderBase.order_status == 10 || result.orderBase.order_status == 20 || result.orderBase.order_status == 40 || result.orderBase.order_status == 50 || result.orderBase.order_status == 60 || result.orderBase.order_status == 70 || result.orderBase.order_status == 80 || result.orderBase.order_status == 90 || result.orderBase.order_status == 100 || result.orderBase.order_status == 110 || result.orderBase.order_status == 9) {
        $("#assassin").hide();
    } else {
        $("#assassin").show();
    }


    if (result.orderExt != null && result.orderExt.final_sent_type == 10) {

        $("#dexpress_company2").show();
        $("#eexpress_num").show();
        $("#cexpress_company").hide();
        $("#bdistributor-phone").hide();
        $("#adriver-phone").hide();
        $("#dexpress_company3").hide();
        $("#eexpress_num3").hide();


    } else if (result.orderExt != null && result.orderExt.final_sent_type == 20) {

        $("#dexpress_company3").show();
        $("#eexpress_num3").show();
        $("#cexpress_company").hide();
        $("#bdistributor-phone").hide();
        $("#adriver-phone").hide();
        $("#dexpress_company2").hide();
        $("#eexpress_num").hide();

    } else if (result.orderExt != null && result.orderExt.final_sent_type == 21) {

        $("#dexpress_company3").show();
        $("#eexpress_num3").show();
        $("#cexpress_company").hide();
        $("#bdistributor-phone").hide();
        $("#adriver-phone").hide();
        $("#dexpress_company2").hide();
        $("#eexpress_num").hide();

    } else if (result.orderExt != null && result.orderExt.final_sent_type == 30) {
        $("#cexpress_company").show();
        $("#adriver-phone").show();
        $("#bdistributor-phone").hide();
        $("#dexpress_company2").hide();
        $("#eexpress_num").hide();
        $("#dexpress_company3").hide();
        $("#eexpress_num3").hide();
    } else if (result.orderExt != null && result.orderExt.final_sent_type == 40) {
        $("#adriver-phone").show();
        $("#bdistributor-phone").show();
        $("#isSasssas").hide();
        $("#issdvssas").hide();
        $("#jshfjshd").show();
        $("#cexpress_company").hide();
        $("#dexpress_company2").hide();
        $("#eexpress_num").hide();
        $("#dexpress_company3").hide();
        $("#eexpress_num3").hide();
    } else if (result.orderExt != null && result.orderExt.final_sent_type == 50) {
        $("#adriver-phone").hide();
        $("#bdistributor-phone").hide();
        $("#cexpress_company").hide();
        $("#dexpress_company2").hide();
        $("#eexpress_num").hide();
        $("#dexpress_company3").hide();
        $("#eexpress_num3").hide();
    } else if (result.orderExt != null && result.orderExt.final_sent_type == 0) {
        $("#adriver-phone").hide();
        $("#bdistributor-phone").hide();
        $("#cexpress_company").hide();
        $("#dexpress_company2").hide();
        $("#eexpress_num").hide();
        $("#dexpress_company3").hide();
        $("#eexpress_num3").hide();
    }


    if (result.is_rejected != null && result.is_rejected == 1) {
        if (result.orderRefund != null && result.orderRefund.refund_status == 30) {
            $("#order_statue1").show();
            $("#order_statue2").hide();
            $("#returnGoods1").hide();
        } else {
            $("#order_statue1").hide();
            $("#order_statue2").hide();
            $("#returnGoods1").hide();
        }
    } else {
        $("#order_statue1").hide();
        $("#order_statue2").hide();
        $("#returnGoods1").hide();
    }
    if (result.is_rejected != null && result.is_rejected == 0) {
        if (result.orderCancleApply != null && result.orderCancleApply.deal_status == 10) {

            $("#order_statue1").show();
            $("#order_statue2").show();
            $("#returnGoods1").hide();

        } else if (result.orderCancleApply != null && result.orderCancleApply.deal_status == 20) {

            $("#order_statue1").show();
            $("#order_statue2").hide();
            $("#returnGoods1").show();

        } else if (result.orderCancleApply != null && result.orderCancleApply.deal_status == 30) {
            $("#order_statue1").hide();
            $("#order_statue2").hide();
            $("#returnGoods1").hide();
        }
    }


    console.log(result)
    sessionStorage.setItem("orderDetail", JSON.stringify(result));
    renderOrderPage(result);
    if (result.listOrderRefund != null) {
        var listOrderRefunds = ""
        $.each(result.listOrderRefund, function(k, v) {
            var d = new Date(v.created_at);
            var cat = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();

            listOrderRefunds += '<tr><td class="col-2-1">退货单号：<span id="returnId"></span><a onclick="returnOrderInfo(\'退货单详情\',\'../channelaftersale/afterSaleService-returns.html\',\'' + v.refund_id + '\',\'' + v.order_id + '\')">' + v.refund_id + '</a></td><td class="col-2-1">申请时间：<span id="applytime"></span><span>' + cat + '</span></td></tr>';
        })
        $("#returnTable").empty().append($(listOrderRefunds))

    }
    //将所有按钮隐藏
    $("#affirmMoney").siblings().css({
        display: "none"
    });
    /*确认认款按钮判断*/
    if ((result.orderBase.paid_type == 1301 || result.orderBase.paid_type == 1401) &&
        (result.orderBase.order_status == 9 || result.orderBase.order_status == 10)) {

        if (result.orderBase.customer_verify_status == 0) {

            $("#affirmMoney").css({
                display: "none"
            });
        }

        if (result.orderBase.customer_verify_status == 10) {
            $("#orderAnomalCheckStatus").css({
                display: "none"
            });
            $("#affirmMoney").css({
                display: "inline"
            });
        }

    } else if (result.orderBase.paid_type == 1101 && result.orderBase.order_status == 70) {
        if (result.listOrderRemark.length == 0) {
            $("#comfirmMoneyRemark").val("");
            $("#affirmMoney").css({
                display: "inline"
            })
        } else {
            for (var i = 0; i < result.listOrderRemark.length; i++) {
                if (result.listOrderRemark[i].operate_type == 10) {
                    $("#affirmMoney").css({
                        display: "inline"
                    })
                    $("#comfirmMoneyRemark").html(result.listOrderRemark[i].remark); //确认认款备注
                } else {
                    $("#comfirmMoneyRemark").val("");
                    $("#affirmMoney").css({
                        display: "inline"
                    });
                }
            }
        }
    }
    ordersts = result.orderBase.order_status;
    orderSplitStatus = result.orderBase.order_split_status;
    switch (result.orderBase.order_status) {
        case 9:

            if (result.listOrderVerifyRecord != null && result.listOrderVerifyRecord != '') {
                for (var i = 0; i < result.listOrderVerifyRecord.length; i++) {

                    if (result.listOrderVerifyRecord[i].account_type == 10 && result.listOrderVerifyRecord[i].verify_status == 0) {
                        console.log('客户');

                        $("#customerCheckdsgs").css({
                            display: "inline"
                        });
                        $("#customerServiceCheckdfh").css({
                            display: "none"
                        });
                    }
                }
            }

            if (result.orderBase.anomal_check == 10 && result.orderBase.order_status == 20) {
                console.log('客服');

                $("#customerServiceCheckdfh").css({
                    display: "inline"
                });
                $("#customerCheckdsgs").css({
                    display: "none"
                });
            }
            $("#detailCancel").css({
                display: "none"
            });

            break;

        case 10:

            $("#detailCancel").css({
                display: "none"
            });

            console.log("121211121");
            /*待付款*/
            $("#da").css({
                display: "inline"
            });
            $("#ca").css({
                display: "inline"
            });
            if (result.listOrderVerifyRecord != null && result.listOrderVerifyRecord != '') {
                for (var i = 0; i < result.listOrderVerifyRecord.length; i++) {
                    if (result.listOrderVerifyRecord[i].account_type == 10 && result.listOrderVerifyRecord[i].verify_status == 0) {
                        console.log('客户');

                        $("#customerCheckdsgs").css({
                            display: "inline"
                        });
                        $("#customerServiceCheckdfh").css({
                            display: "none"
                        });
                    }
                }
            }

            if (result.orderBase.anomal_check == 10) {
                console.log('客服');

                $("#customerServiceCheckdfh").css({
                    display: "inline"
                });
                $("#customerCheckdsgs").css({
                    display: "none"
                });
            }


            if (result.submitState == 20) {
                $("#detailCancel").css({
                    display: "none"
                });
                $("#pass").css({
                    display: "none"
                });
                $("#demolitionOrder").css({
                    display: "none"
                });
                $("#quxiao").css({
                    display: "inline"
                });
            }


            break;
            /*订单状态*/
        case 20:
            //待审核 isTpaOrder 为10是服务商订单不展示按钮

            $("#orderCategoryModify").css({
                display: "inline"
            });
            $("#warehouseIdModify").css({
                display: "inline"
            });
            $("#secondarysenttypeModify").css({
                display: "inline"
            });
            $("#senttypeModify").css({
                display: "inline"
            });

            if (results.data.parent_customer_code == 'UW00000001' || results.data.parent_customer_code == 'GJP0000001' || results.data.parent_customer_code == 'D000000033' || results.data.isTpaOrder == 10) {
                $("#orderCategoryModify2").removeAttr("onclick")
                $("#orderCategoryModify2").attr("style", "color: #aaaaaa;")
                $("#orderCategoryModify3").removeAttr("onclick")
                $("#orderCategoryModify3").attr("style", "color: #aaaaaa;")
                $("#orderCategoryModify4").removeAttr("onclick")
                $("#orderCategoryModify4").attr("style", "color: #aaaaaa;")
                $("#orderCategoryModify5").removeAttr("onclick")
                $("#orderCategoryModify5").attr("style", "color: #aaaaaa;")
            } else {
                /*   if(results.data.exception_type.match(40)||results.data.exception_type.match(120)||results.data.exception_type.match(160)){
                       $("#orderCategoryModify2").removeAttr("style")
                       $("#orderCategoryModify2").attr("onclick","orderCategoryModify()")
                   }else {
                       $("#orderCategoryModify2").removeAttr("onclick")
                       $("#orderCategoryModify2").attr("style","color: #aaaaaa;")
                   }*/
                $("#orderCategoryModify2").removeAttr("style")
                $("#orderCategoryModify2").attr("onclick", "orderCategoryModify()")

                $("#orderCategoryModify3").removeAttr("style")
                $("#orderCategoryModify3").attr("onclick", "warehouseIdModify()")


                $("#orderCategoryModify4").removeAttr("style")
                $("#orderCategoryModify4").attr("onclick", "secondarysenttypeModify()")


                $("#orderCategoryModify5").removeAttr("style")
                $("#orderCategoryModify5").attr("onclick", "senttypeModify()")

            }
            if (results.data.isAuditRejection == "0" && results.data.isTpaOrder != 10 && results.data.isBidding != 1) {
                $("#detailCancel").css({
                    display: "inline"
                });
            }
            if (results.data.isTpaOrder != 10) {
                $("#pass").css({
                    display: "inline"
                });
            }
            $("#da").css({
                display: "inline"
            });
            $("#ca").css({
                display: "inline"
            });
            $("#estimate").css({
                display: "inline"
            });

            if (results.data.parent_customer_code != "DJ00000007") {
                $("#qualificationType").css({
                    display: "inline"
                });
                $("#zizhi").css({
                    display: "inline"
                });
            } else {

                $("#zizhi").css({
                    display: "inline"
                });

                $("#qualificationType").css({
                    display: "inline"
                });

                $("#qualification_documents").val(results.data.orderBase.quality_file_required);

                if (results.data.orderBase.quality_file_required == 10) { //需要资质
                    $("#is_qualification").attr("checked", "checked");
                    $("#qualification").css({
                        display: "inline"
                    });
                    $("#qualification_number").val(results.data.orderExt.file_copies) //分数
                } else {
                    $("#qualification").css({
                        display: "none"
                    });
                    $("#qualification_number").val("0");
                    $("input[name=qiding]:checked").val("0")

                }
            }


            if (result.listOrderVerifyRecord != null && result.listOrderVerifyRecord != '') {
                for (var i = 0; i < result.listOrderVerifyRecord.length; i++) {

                    if (result.listOrderVerifyRecord[i].account_type == 10 && result.listOrderVerifyRecord[i].verify_status == 0) {
                        console.log('客户');
                        $("#customerCheckdsgs").css({
                            display: "inline"
                        });
                        $("#customerServiceCheckdfh").css({
                            display: "none"
                        });
                    }
                }
            }
            if (result.orderBase.anomal_check == 10) {
                console.log('客服');
                $("#customerServiceCheckdfh").css({
                    display: "inline"
                });
                $("#customerCheckdsgs").css({
                    display: "none"
                });
            }

            $("#affirmMoney").css({
                display: "none"
            });
            $("#orderSureStatus").css({
                display: "none"
            });
            //拆单按钮控制0
            /* 不再使用match匹配方法，会有冲突，进行字符串切割成数组，包含40为真，否则为假 */
            // results.data.exception_type = "120,40"
            var exceptionType = results.data.exception_type.split(',')
            var isOverSaleFlag = exceptionType.indexOf('40')
            var isOverSaleFlag2 = exceptionType.indexOf('120')
            var isOverSaleFlag3 = exceptionType.indexOf('160')
            if (results.data.isBidding == 1 && results.data.orderBase.order_status && ((isOverSaleFlag !== -1) || (isOverSaleFlag2 !== -1) || (isOverSaleFlag3 !== -1)) && results.data.isSplit == 0 && results.data.orderBase.order_split_status != 20) {
                $("#demolitionOrder").css({
                    display: "inline"
                });
            } else {
                if (results.data.isSplit == 0 && ((isOverSaleFlag !== -1) || (isOverSaleFlag2 !== -1) || (isOverSaleFlag3 !== -1)) && results.data.orderBase.order_split_status != 20) {
                    $("#demolitionOrder").css({
                        display: "inline"
                    });
                }
            }

            /*待审核*/
            if (result.orderBase.order_split_status != 0) {
                $("#detailCancel").css({
                    display: "none"
                });
                $("#pass").css({
                    display: "none"
                });

                $("#da").css({
                    display: "none"
                });
                $("#ca").css({
                    display: "none"
                });
                $("#estimate").css({
                    display: "none"
                });
            }
            if (result.submitState == 20) {
                $("#detailCancel").css({
                    display: "none"
                });
                $("#pass").css({
                    display: "none"
                });
                $("#demolitionOrder").css({
                    display: "none"
                });
                $("#quxiao").css({
                    display: "inline"
                });
            }
            if (result.orderBase.get) {

            }
            break;
        case 30:
            /*待配货*/

            $("#affirmMoney").css({
                display: "none"
            });
            $(".updataBtn").css({
                display: "inline"
            });
            $("#detailCancel").css({
                display: "none"
            });

            //订单下推
            if (result.push_button_show == true) {
                $("#pushOrder").css({
                    display: "inline"
                });
                $("#pushOrder2").css({
                    display: "inline"
                });
            } else {
                $("#pushOrder").css({
                    display: "none"
                });
                $("#pushOrder2").css({
                    display: "none"
                });
            }

            break;
        case 40:
            /*待出库*/
            if (result.cancle_apply_show == false) {
                $("#quxiao").css({
                    display: "inline"
                });


            } else {
                /* var b = 0;
                 var arr = result.normalPricePreOrderItemsList
                 for (var i = 0; i < arr.length; i++) {
                     var a = arr[i].can_returned_count;
                     if (a != 0) {
                         b = 1;
                     }
                 }
                 // if(results.data.parent_customer_code!="DJ00000006") {
                 if (b != 0) {
                     if(results.data.parent_customer_code != "D000000025" && results.data.parent_customer_code != "D000000051" && results.data.parent_customer_code != "D000000018" && results.data.parent_customer_code != "D000000022"){
                         $("#cancelorder").css({
                             display: "inline"
                         });
                     }
                 }*/
                // }
            }

            if (results.data.isCancelOrder == "0" && results.data.isTpaOrder != 10) {
                $("#cancelorder").css({
                    display: "inline"
                });
            }

            $("#pushOrder").css({
                display: "none"
            });
            $("#pushOrder2").css({
                display: "none"
            });

            $("#affirmMoney").css({
                display: "none"
            });

            $("#jshfjshd").css({
                display: "none"
            });
            $("#detailCancel").css({
                display: "none"
            });
            console.log("result===:" + result.orderExt.common_order_type);
            if (results.data.orderBase.order_status == 40 && results.data.orderExt.common_order_type == 19653 && results.data.cancle_apply_show == true) {
                $("#frglivergoods").css({
                    display: "inline"
                });
            }
            if (result.orderExt.common_order_type == 19653) {

                $("#delivery-method").html("厂家直发");
            } else {

                $("#delivery-method").html(changeDeliverthodType(result.orderExt.sent_type));

            }


            function changeDeliverthodType(DeliveryMethodType) {
                switch (DeliveryMethodType) {
                    /*配送方式*/
                    case 10:
                        return "快递";
                        break;
                    case 20:
                        return "快运-送货上门";
                        break;
                    case 30:
                        return "快运-站点自提";
                        break;
                    case 40:
                        return "鑫方盛物流";
                        break;
                    case 50:
                        return "上门自提";
                        break;

                }
            }

            break;
        case 50:
            /*待发货*/
            if (result.cancle_apply_show == false) {
                $("#quxiao").css({
                    display: "inline"
                });

            } else {
                // if(results.data.parent_customer_code!="DJ00000006") {
                /*  var b = 0;
                  var arr = result.normalPricePreOrderItemsList
                  for (var i = 0; i < arr.length; i++) {
                      var a = arr[i].can_returned_count;
                      if (a != 0) {
                          b = 1;
                      }
                  }
                  // if(results.data.parent_customer_code!="DJ00000006") {
                  if (b != 0) {
                      if(results.data.parent_customer_code != "D000000025" && results.data.parent_customer_code != "D000000051" && results.data.parent_customer_code != "D000000018"  && results.data.parent_customer_code != "D000000022") {
                          $("#cancelorder").css({
                              display: "inline"
                          });
                      }
                  }*/
                // }

            }
            if (results.data.isCancelOrder == "0" && results.data.isTpaOrder != 10) {
                $("#cancelorder").css({
                    display: "inline"
                });
            }
            $("#affirmMoney").css({
                display: "none"
            });

            $("#detailCancel").css({
                display: "none"
            });

            $("#pushOrder").css({
                display: "none"
            });
            $("#pushOrder2").css({
                display: "none"
            });
            break;
        case 60:
            $("#pushOrder").css({
                display: "none"
            });
            $("#pushOrder2").css({
                display: "none"
            });

            console.log("11111111111111111111111111")
                /*待收货*/
            if (result.orderExt.final_sent_type != 40) {
                if (results.data.parent_customer_code != "D000000025") {
                    $("#receiving").css({
                        display: "inline"
                    });
                }
            }

            $("#uploadProof").css({
                display: "inline"
            });

            if (results.data.uploadProofStatus == 1) {
                $("#checkProof").css({
                    display: "inline"
                });
            }

            if (result.orderExt.final_sent_type == 40) {
                $("#issdvssas").css({
                    display: "none"
                });
                $("#isSasssas").css({
                    display: "none"
                });

            } else {
                $("#issdvssas").css({
                    display: "inline"
                });
                $("#isSasssas").css({
                    display: "inline"
                });
            }


            $("#affirmMoney").css({
                display: "none"
            });


            $("#isSvssas").css({
                display: "inline"
            });
            $("#isSasdvssas").css({
                display: "inline"
            });
            $("#isSasdseFalse").css({
                display: "inline"
            });
            $("#isSasdeFalse").css({
                display: "inline"
            });
            $("#ieFalse").css({
                display: "inline"
            });
            $("#ieFlse").css({
                display: "inline"
            });

            if (result.is_rejected != 1) {
                if (results.data.parent_customer_code != "D000000025" && results.data.parent_customer_code != "D000000018" && results.data.parent_customer_code != "D000000022") {
                    $("#clientRejection").css({
                        display: "inline"
                    });
                }
            }
            if (result.orderExt.final_sent_type != 40) {
                $("#logisticsInformations").css({
                    display: "inline"
                });
            }
            break;
        case 70:
            $("#pushOrder").css({
                display: "none"
            });
            $("#pushOrder2").css({
                display: "none"
            });

            /*已收货，待结算*/
            if (result.is_show == true) {
                if (results.data.parent_customer_code != "DJ00000006" && results.data.parent_customer_code != "D000000025" && results.data.parent_customer_code != "D000000051" && results.data.parent_customer_code != "D000000022" && results.data.parent_customer_code != "D000000018") {
                    $("#maintain").css({
                        display: "inline"
                    });

                    if (results.data.parent_customer_code != "D000000025" && results.data.parent_customer_code != "D000000051" && results.data.parent_customer_code != "D000000022" && results.data.parent_customer_code != "D000000018") {
                        $("#returnGoods").css({
                            display: "inline"
                        });
                    }
                }
            }
            $("#uploadProof").css({
                display: "inline"
            });

            if (results.data.uploadProofStatus == 1) {
                $("#checkProof").css({
                    display: "inline"
                });
            }
            if (result.orderExt.final_sent_type != 40) {
                $("#logisticsInformations").css({
                    display: "inline"
                });
            }
            break;
        case 80:
            /*订单成功*/
            $("#pushOrder").css({
                display: "none"
            });
            $("#pushOrder2").css({
                display: "none"
            });

            $("#affirmMoney").css({
                display: "none"
            });

            $("#uploadProof").css({
                display: "inline"
            });

            if (results.data.uploadProofStatus == 1) {
                $("#checkProof").css({
                    display: "inline"
                });
            }

            if (result.is_show == true) {
                if (results.data.parent_customer_code != "DJ00000006" && results.data.parent_customer_code != "D000000025" && results.data.parent_customer_code != "D000000051" && results.data.parent_customer_code != "D000000022" && results.data.parent_customer_code != "D000000018") {
                    $("#maintain").css({
                        display: "inline"
                    });
                    if (results.data.parent_customer_code != "D000000025" && results.data.parent_customer_code != "D000000051" && results.data.parent_customer_code != "D000000022" && results.data.parent_customer_code != "D000000018") {
                        $("#returnGoods").css({
                            display: "inline"
                        });
                    }
                }
            }
            /* $("#returnInfoBox").css({
                 display: "block"
             });*/
            if (result.orderExt.final_sent_type != 40) {
                $("#logisticsInformations").css({
                    display: "inline"
                });
            }
            break;
        case 90:
            /*交易完成*/
            $("#pushOrder").css({
                display: "none"
            });
            $("#pushOrder2").css({
                display: "none"
            });

            $("#affirmMoney").css({
                display: "none"
            });

            $("#uploadProof").css({
                display: "inline"
            });

            if (results.data.uploadProofStatus == 1) {
                $("#checkProof").css({
                    display: "inline"
                });
            }

            if (result.is_show == true) {
                if (results.data.parent_customer_code != "DJ00000006" && results.data.parent_customer_code != "D000000025" && results.data.parent_customer_code != "D000000051" && results.data.parent_customer_code != "D000000022" && results.data.parent_customer_code != "D000000018") {
                    $("#maintain").css({
                        display: "inline"
                    });
                    if (results.data.parent_customer_code != "D000000025" && results.data.parent_customer_code != "D000000051" && results.data.parent_customer_code != "D000000022" && results.data.parent_customer_code != "D000000018") {
                        $("#returnGoods").css({
                            display: "inline"
                        });
                    }
                }
            }
            if (result.orderExt.final_sent_type != 40) {
                $("#logisticsInformations").css({
                    display: "inline"
                });
            }
            break;
        case 100:
            /*已取消*/
            $("#pushOrder").css({
                display: "none"
            });
            $("#pushOrder2").css({
                display: "none"
            });

            $("#affirmMoney").css({
                display: "none"
            });
            $("#orderSureStatus").css({
                display: "none"
            });
            $("#customerCheck").hide();
            $("#customerServiceCheck").hide();
            if (result.buy_again_button == true) {
                $("#buyAgain").css({
                    display: "inline"
                });
            } else {
                $("#buyAgain").css({
                    display: "none"
                });
            }

            $("#cancleReason").css({
                display: "inline"
            });
            if (result.orderCancle.cancel_role == 10) {
                $("#cancleReason").html("客户主动取消");
            } else if (result.orderCancle.cancel_role == 20) {
                $("#cancleReason").html("客服取消");
            } else if (result.orderCancle.cancel_role == 30) {
                $("#cancleReason").html("超时未支付取消");
            }
            $(".cancleBox").css({
                display: "inline"
            });
            /*$("#returnInfoBox").css({
                display: "block"
            });*/
            if (result.orderExt.final_sent_type != 40) {
                $("#logisticsInformations").css({
                    display: "inline"
                });
            }
            break;
        case 110:
            /*交易关闭*/
            $("#pushOrder").css({
                display: "none"
            });
            $("#pushOrder2").css({
                display: "none"
            });
            $("#returnReason").css({
                display: "inline"
            });
            $("#affirmMoney").css({
                display: "none"
            });
            /* $("#returnInfoBox").css({
                 display: "block"
             });*/
            $(".closeBox").css({
                display: "block"
            });
            if (result.orderExt.final_sent_type != 40) {
                $("#logisticsInformations").css({
                    display: "inline"
                });
            }
    }


    var handStr = '';
    var hdStr = '';
    var hdStrdf = ""
    var hdStrdfuu = ""
    var hdSdfuu = ""
    var hdSyicu = ""
        //满减金额商品
    if (result.fullAmountReduceOrderItemsMap != "" && result.fullAmountReduceOrderItemsMap != null) {
        var arr = result.fullAmountReduceOrderItemsMap
        $.each(arr, function(index, i) {
            //算出该活动的所有商品小计和优惠值
            let countMoney = 0;
            let promotionMoney = 0;
            $.each(arr[index], function(k, v) {
                promotionMoney = Number(promotionMoney) + Number(v.promotion_value);
                countMoney = Number(countMoney) + Number((v.sale_price * v.buyyer_count).toFixed(2));
            })

            let ruleStr = '<tr><td colspan="11"><div>' +
                '<span style="float: left;">' + arr[index][0].activity_rule + '</span>' +
                '<div style="float: right"><span style="float: left;">￥' + (countMoney).toFixed(2) + '</span><br>' +
                '<span style="float: left;">减：' + (promotionMoney).toFixed(2) + '</span></div>' +
                '</div></td></tr>';
            handStr += ruleStr;

            $.each(arr[index], function(k, v) {
                console.log(arr[index])

                var ss = ""
                $.each(warehouses.data, function(k, s) {
                        if (result.orderBase.parent_warehouse_id == s.warehouseCode) {
                            ss = s.warehouseName
                        }
                    })
                    //单价
                var price = v.sale_price
                var specialPrice = ""
                if (v.activity_type == 10) {
                    specialPrice = v.promotion_value / v.buyyer_count
                }
                price = (price - specialPrice).toFixed(2)
                    //运费分摊
                var fares = ""
                if (result.orderBase.separate_shipping_fee == 10) {
                    fares = "0"
                } else {
                    fares = v.fare

                }
                //满减券分摊
                var couponvalues = ""
                if (result.orderCoupon != "" && result.orderCoupon != null) {

                    if (result.orderCoupon.coupon_type == 10) {
                        couponvalues = v.coupon_value
                    } else {
                        couponvalues = "0"
                    }
                }
                //小计
                var substotle = (price * v.buyyer_count).toFixed(2);
                var product_types = ""
                if (v.product_type == 10) {
                    product_types = "临采"
                } else if (v.product_type == 20) {
                    product_types = "正常"
                } else if (v.product_type == 30) {
                    product_types = "服务商"
                }
                var product_typeall = ''
                if (v.product_type == 30) {
                    product_typeall = '<span id="consignee" onmousemove="producttypeover(\'' + v.sku_code + '\')" onmouseout="producttypeout(\'' + v.sku_code + '\')" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;width:50px;display:inline-block;">' + product_types + '</span> <div id="mouseBox' + v.sku_code + '" style="position:absolute;max-width: 163px; background: #fff;padding:10px;border:1px solid #ccc;display:none;">' + v.commoditySourceName + '</div>'
                } else {
                    product_typeall = '<span id="handle_mans">' + product_types + '</span>'
                }
                var channeldata = ''
                if (isBiddingdata) {
                    channeldata = '<td class="biaoge1-1"><div><span>物料ID：</span><span>' + v.channelMaterialId + '</span></div><div><span>物料名称：</span><span>' + v.channelCategory + '</span></div><div><span>品牌：</span><span>' + v.channelBrandName + '</span></div><div><span>规格：</span><span>' + v.channelModel + '</span></div><div><span>单位：</span><span>' + v.channelUnit + '</span></div></td>'
                }
                if (v.spu_id == 0) {
                    if (v.occupy_virtual_store > 0) {
                        handStr += '<tr class="biaoge1" bgcolor="#ffb6c1 ">' + channeldata +

                            '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                            '<td class="biaoge1-1">' + product_typeall + '</td>' +
                            '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-6"><span id="create_time">' + v.occupy_store + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                            '</tr>';
                    } else {
                        handStr += '<tr class="biaoge1">' + channeldata +
                            '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                            '<td class="biaoge1-1">' + product_typeall + '</td>' +
                            '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-6"><span id="create_time">' + v.occupy_store + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                            '</tr>';
                    }

                } else {
                    if (v.occupy_virtual_store > 0) {
                        handStr += '<tr class="biaoge1" bgcolor="#ffb6c1 ">' + channeldata +
                            '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="点击跳转sku列表" onclick="goToGoodsDetail(' + v.spu_id + ')"  style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                            '<td class="biaoge1-1">' + product_typeall + '</td>' +
                            '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-6"><span id="create_time">' + v.occupy_store + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                            '</tr>';
                    } else {
                        handStr += '<tr class="biaoge1">' + channeldata +
                            '<td class="biaoge1-1">' + product_typeall + '</td>' +
                            '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-6"><span id="create_time">' + v.occupy_store + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                            '</tr>';
                    }

                }
            })


        })
    }
    //数量商品
    if (result.fullQuantityReduceOrderItemsMap != "" && result.fullQuantityReduceOrderItemsMap != null) {
        var arr = result.fullQuantityReduceOrderItemsMap
        $.each(arr, function(index, i) {
            //算出该活动的所有商品小计和优惠值
            let countMoney = 0;
            let promotionMoney = 0;
            $.each(arr[index], function(k, v) {
                promotionMoney = Number(promotionMoney) + Number(v.promotion_value);
                countMoney = Number(countMoney) + Number((v.sale_price * v.buyyer_count).toFixed(2));
            })

            let ruleStre = '<tr><td colspan="11"><div>' +
                '<span style="float: left;">' + arr[index][0].activity_rule + '</span>' +
                '<div style="float: right"><span style="float: left;">￥' + countMoney + '</span><br>' +
                '<span style="float: left;">减：' + promotionMoney + '</span></div>' +
                '</div></td></tr>';
            hdStrdf += ruleStre;

            $.each(arr[index], function(k, v) {
                console.log(arr[index])

                var ss = ""
                $.each(warehouses.data, function(k, s) {
                    if (result.orderBase.parent_warehouse_id == s.warehouseCode) {
                        ss = s.warehouseName
                    }
                })
                var price = v.sale_price

                var specialPrice = ""
                if (v.activity_type == 10) {
                    specialPrice = v.promotion_value / v.buyyer_count
                }
                price = (price - specialPrice).toFixed(2)

                //运费分摊
                var fares = ""
                if (result.orderBase.separate_shipping_fee == 10) {
                    fares = "0"
                } else {
                    fares = v.fare

                }
                //满减券分摊
                var couponvalues = ""
                if (result.orderCoupon != "" && result.orderCoupon != null) {

                    if (result.orderCoupon.coupon_type == 10) {
                        couponvalues = v.coupon_value
                    } else {
                        couponvalues = "0"
                    }
                }
                console.log("运费" + fares)
                var substotle = (price * v.buyyer_count).toFixed(2);

                var product_types = ""
                if (v.product_type == 10) {
                    product_types = "临采"
                } else if (v.product_type == 20) {
                    product_types = "正常"
                } else if (v.product_type == 30) {
                    product_types = "服务商"
                }
                var product_typeall = ''
                if (v.product_type == 30) {
                    product_typeall = '<span id="consignee" onmousemove="producttypeover(\'' + v.sku_code + '\')" onmouseout="producttypeout(\'' + v.sku_code + '\')" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;width:50px;display:inline-block;">' + product_types + '</span> <div id="mouseBox' + v.sku_code + '" style="position:absolute;max-width: 163px; background: #fff;padding:10px;border:1px solid #ccc;display:none;">' + v.commoditySourceName + '</div>'
                } else {
                    product_typeall = '<span id="handle_mans">' + product_types + '</span>'
                }
                var channeldata = ''
                if (isBiddingdata) {
                    channeldata = '<td class="biaoge1-1"><div><span>物料ID：</span><span>' + v.channelMaterialId + '</span></div><div><span>物料名称：</span><span>' + v.channelCategory + '</span></div><div><span>品牌：</span><span>' + v.channelBrandName + '</span></div><div><span>规格：</span><span>' + v.channelModel + '</span></div><div><span>单位：</span><span>' + v.channelUnit + '</span></div></td>'
                }
                if (v.spu_id == 0) {
                    if (v.occupy_virtual_store > 0) {
                        hdStrdf += '<tr class="biaoge1" bgcolor="#ffb6c1 ">' + channeldata +
                            '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                            '<td class="biaoge1-1">' + product_typeall + '</td>' +
                            '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-6"><span id="create_time">' + v.occupy_store + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                            '</tr>';
                    } else {
                        if (v.occupy_virtual_store > 0) {
                            hdStrdf += '<tr class="biaoge1" bgcolor="#ffb6c1 ">' + channeldata +
                                '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                '<td class="biaoge1-1">' + product_typeall + '</td>' +
                                '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                '<td class="biaoge1-6"><span id="create_time">' + v.occupy_store + '' + v.unit_name + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                '</tr>';
                        } else {
                            hdStrdf += '<tr class="biaoge1">' + channeldata +
                                '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                '<td class="biaoge1-1">' + product_typeall + '</td>' +
                                '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                '<td class="biaoge1-6"><span id="create_time">' + v.occupy_store + '' + v.unit_name + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                '</tr>';
                        }

                    }
                } else {
                    hdStrdf += '<tr class="biaoge1">' + channeldata +
                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="点击跳转sku列表" onclick="goToGoodsDetail(' + v.spu_id + ')"  style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                        '<td class="biaoge1-1">' + product_typeall + '</td>' +
                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-6"><span id="create_time">' + v.occupy_store + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                        '</tr>';
                }
            })


        })
    }
    //特价商品
    if (result.specialPriceOrderItemsList != "" && result.specialPriceOrderItemsList != null) {
        var arr = result.specialPriceOrderItemsList

        //算出该活动的所有商品小计和优惠值
        let ii = ""
        let ruleStret = '<tr><td colspan="11"><div>' +
            '<span style="float: left;">' + ii + '</span>' +
            /*'<div style="float: right"><span style="float: left;">￥'+countMoney+'</span><br>' +
            '<span style="float: left;">减：'+promotionMoney+'</span></div>' +*/
            '</div></td></tr>';
        hdStrdfuu += ruleStret;

        $.each(arr, function(k, v) {

            var ss = ""
            $.each(warehouses.data, function(k, s) {
                if (result.orderBase.parent_warehouse_id == s.warehouseCode) {
                    ss = s.warehouseName
                }
            })
            var price = v.sale_price

            var specialPrice = ""
            if (v.activity_type == 10) {
                specialPrice = v.promotion_value / v.buyyer_count
            }
            price = (price - specialPrice).toFixed(2)

            //运费分摊
            var fares = ""
            if (result.orderBase.separate_shipping_fee == 10) {
                fares = "0"
            } else {

                fares = v.fare
            }
            //满减券分摊
            var couponvalues = ""
            if (result.orderCoupon != "" && result.orderCoupon != null) {

                if (result.orderCoupon.coupon_type == 10) {
                    couponvalues = v.coupon_value
                } else {
                    couponvalues = "0"
                }
            }
            var substotle = (price * v.buyyer_count).toFixed(2);

            var product_types = ""
            if (v.product_type == 10) {
                product_types = "临采"
            } else if (v.product_type == 20) {
                product_types = "正常"
            } else if (v.product_type == 30) {
                product_types = "服务商"
            }
            var product_typeall = ''
            if (v.product_type == 30) {
                product_typeall = '<span id="consignee" onmousemove="producttypeover(\'' + v.sku_code + '\')" onmouseout="producttypeout(\'' + v.sku_code + '\')" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;width:50px;display:inline-block;">' + product_types + '</span> <div id="mouseBox' + v.sku_code + '" style="position:absolute;max-width: 163px; background: #fff;padding:10px;border:1px solid #ccc;display:none;">' + v.commoditySourceName + '</div>'
            } else {
                product_typeall = '<span id="handle_mans">' + product_types + '</span>'
            }
            var channeldata = ''
            if (isBiddingdata) {
                channeldata = '<td class="biaoge1-1"><div><span>物料ID：</span><span>' + v.channelMaterialId + '</span></div><div><span>物料名称：</span><span>' + v.channelCategory + '</span></div><div><span>品牌：</span><span>' + v.channelBrandName + '</span></div><div><span>规格：</span><span>' + v.channelModel + '</span></div><div><span>单位：</span><span>' + v.channelUnit + '</span></div></td>'
            }
            if (v.spu_id == 0) {
                if (v.occupy_virtual_store > 0) {
                    hdStrdfuu += '<tr class="biaoge1" bgcolor="#ffb6c1 ">' + channeldata +
                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                        '<td class="biaoge1-1">' + product_typeall + '</td>' +
                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-6"><span id="create_time">' + v.occupy_store + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><div><input style="width: 32px;background-color: yellow;" value="特价" readonly="readonly"></div><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + "0" + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                        '</tr>';
                } else {
                    hdStrdfuu += '<tr class="biaoge1">' + channeldata +
                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                        '<td class="biaoge1-1">' + product_typeall + '</td>' +
                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-6"><span id="create_time">' + v.occupy_store + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><div><input style="width: 32px;background-color: yellow;" value="特价" readonly="readonly"></div><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + "0" + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                        '</tr>';
                }

            } else {
                if (v.occupy_virtual_store > 0) {
                    hdStrdfuu += '<tr class="biaoge1" bgcolor="#ffb6c1 ">' + channeldata +
                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="点击跳转sku列表" onclick="goToGoodsDetail(' + v.spu_id + ')" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                        '<td class="biaoge1-1">' + product_typeall + '</td>' +
                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-6"><span id="create_time">' + v.occupy_store + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><div><input style="width: 32px;background-color: yellow;" value="特价" readonly="readonly"></div><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + "0" + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                        '</tr>';
                } else {
                    hdStrdfuu += '<tr class="biaoge1">' + channeldata +
                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="点击跳转sku列表" onclick="goToGoodsDetail(' + v.spu_id + ')" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                        '<td class="biaoge1-1">' + product_typeall + '</td>' +
                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-6"><span id="create_time">' + v.occupy_store + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><div><input style="width: 32px;background-color: yellow;" value="特价" readonly="readonly"></div><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + "0" + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                        '</tr>';
                }

            }
        })


    }
    var a = 0;
    if (result.normalPricePreOrderItemsList != "" && result.normalPricePreOrderItemsList != null) {
        var arr = result.normalPricePreOrderItemsList
            //算出该活动的所有商品小计和优惠值
        let ii = ""
        let ruleStret = '<tr><td colspan="11"><div>' +
            '<span style="float: left;">' + ii + '</span>' +

            '</div></td></tr>';
        hdSdfuu += ruleStret;

        $.each(arr, function(k, v) {
            console.log(result.orderBase.parent_warehouse_id)
            console.log("临采", v.is_temp_sku)
            if (v.is_temp_sku == 0) {
                console.log("12123+", v.is_temp_sku)
                    // localStorage.setItem("mask",123);
                    /*var fahuo=2;
                    win.fahuo=fahuo;*/
                fahuo = "a";
                arrs.push(v.is_temp_sku)
                    /*console.log("数组长度",arrs.length)*/
            }
            console.log("arrs==", arrs)
            var ss = ""
            $.each(warehouses.data, function(k, s) {
                if (result.orderBase.parent_warehouse_id == s.warehouseCode) {
                    ss = s.warehouseName
                }
            })
            var price = v.sale_price

            var specialPrice = ""
            if (v.activity_type == 10) {
                specialPrice = v.promotion_value / v.buyyer_count
            }
            price = (price - specialPrice).toFixed(2)

            //运费分摊
            var fares = ""
            if (result.orderBase.separate_shipping_fee == 10) {
                fares = "0"
            } else {
                fares = v.fare

            }
            //满减券分摊
            var couponvalues = ""
            if (result.orderCoupon != "" && result.orderCoupon != null) {

                if (result.orderCoupon.coupon_type == 10) {
                    couponvalues = v.coupon_value
                } else {
                    couponvalues = "0"
                }
            }
            var substotle = (v.sale_price * v.buyyer_count).toFixed(2);


            var ppoi = ""
            if (v.sale_price < v.cost_price && v.channel_settled_price != v.settled_price) {
                ppoi = "结算价异常值，低于成本价"

            } else if (v.sale_price < v.cost_price) {
                ppoi = "低于成本价"
            } else if (v.channel_settled_price != v.settled_price) {
                ppoi = "结算价异常"
            }
            var product_types = ""
            if (v.product_type == 10) {
                product_types = "临采"
            } else if (v.product_type == 20) {
                product_types = "正常"
            } else if (v.product_type == 30) {
                product_types = "服务商"
            }
            var product_typeall = ''
            if (v.product_type == 30) {
                product_typeall = '<span id="consignee" onmousemove="producttypeover(\'' + v.sku_code + '\')" onmouseout="producttypeout(\'' + v.sku_code + '\')" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;width:50px;display:inline-block;">' + product_types + '</span> <div id="mouseBox' + v.sku_code + '" style="position:absolute;max-width: 163px; background: #fff;padding:10px;border:1px solid #ccc;display:none;">' + v.commoditySourceName + '</div>'
            } else {
                product_typeall = '<span id="handle_mans">' + product_types + '</span>'
            }
            var channeldata = ''
            if (isBiddingdata) {
                channeldata = '<td class="biaoge1-1"><div><span>物料ID：</span><span>' + v.channelMaterialId + '</span></div><div><span>物料名称：</span><span>' + v.channelCategory + '</span></div><div><span>品牌：</span><span>' + v.channelBrandName + '</span></div><div><span>规格：</span><span>' + v.channelModel + '</span></div><div><span>单位：</span><span>' + v.channelUnit + '</span></div></td>'
            }
            if (v.spu_id == 0) {
                if (v.occupy_virtual_store > 0) {
                    hdSdfuu += '<tr class="biaoge1" bgcolor="#ffb6c1 ">' + channeldata +
                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div id = "aaaaa">' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                        '<td class="biaoge1-1">' + product_typeall + '</td>' +
                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-6"><span id="create_time">' + v.occupy_store + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.occupy_virtual_store + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' + //退货
                        '<td class="biaoge1-demolitionOrder_2"><span id="create_time">' + v.channel_settled_price + '元/' + v.unit_name + '</span><br><span style="color: #c62b26">' + ppoi + '</span></td>' +
                        '<td class="biaoge1-demolitionOrder_3"><input type="text" class="input-text mr-5" style="width: 43px;" value=""></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.settled_price + '元/' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                        '</tr>';
                } else {

                    hdSdfuu += '<tr class="biaoge1">' + channeldata +
                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div id = "aaaaa">' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                        '<td class="biaoge1-1">' + product_typeall + '</td>' +
                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-6"><span id="create_time">' + v.occupy_store + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.occupy_virtual_store + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' + //退货
                        '<td class="biaoge1-demolitionOrder_2"><span id="create_time">' + v.channel_settled_price + '元/' + v.unit_name + '</span><br><span style="color: #c62b26">' + ppoi + '</span></td>' +
                        '<td class="biaoge1-demolitionOrder_3"><input type="text" class="input-text mr-5" style="width: 43px;" value=""></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.settled_price + '元/' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                        '</tr>';
                }

            } else {
                if (v.occupy_virtual_store > 0) {
                    hdSdfuu += '<tr class="biaoge1" bgcolor="#ffb6c1 ">' + channeldata +
                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="点击跳转sku列表" onclick="goToGoodsDetail(' + v.spu_id + ')" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div id = "aaaaa">' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                        '<td class="biaoge1-1">' + product_typeall + '</td>' +
                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-6"><span id="create_time">' + v.occupy_store + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.occupy_virtual_store + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' + //退货
                        '<td class="biaoge1-demolitionOrder_2"><span id="create_time">' + v.channel_settled_price + '元/' + v.unit_name + '</span><br><span style="color: #c62b26">' + ppoi + '</span></td>' +
                        '<td class="biaoge1-demolitionOrder_3"><input type="text" class="input-text mr-5" style="width: 43px;" value=""></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.settled_price + '元/' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                        '</tr>';
                } else {
                    hdSdfuu += '<tr class="biaoge1">' + channeldata +
                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="点击跳转sku列表" onclick="goToGoodsDetail(' + v.spu_id + ')" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div id = "aaaaa">' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                        '<td class="biaoge1-1">' + product_typeall + '</td>' +
                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-6"><span id="create_time">' + v.occupy_store + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.occupy_virtual_store + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' + //退货
                        '<td class="biaoge1-demolitionOrder_2"><span id="create_time">' + v.channel_settled_price + '元/' + v.unit_name + '</span><br><span style="color: #c62b26">' + ppoi + '</span></td>' +
                        '<td class="biaoge1-demolitionOrder_3"><input type="text" class="input-text mr-5" style="width: 43px;" value=""></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.settled_price + '元/' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                        '</tr>';
                }

            }
        })

    }
    if (result.listAbnormalOrderItems != "" && result.listAbnormalOrderItems != null) {
        var arr = result.listAbnormalOrderItems

        $.each(arr, function(k, v) {
                console.log(v)

                var ppoi = ""
                if (v.abnormalType == 10) {
                    ppoi = "非我司商品"

                } else if (v.abnormalType == 20) {
                    ppoi = "商品已下架"
                } else if (v.abnormalType == 30) {
                    ppoi = "商品无结算价"
                }

                hdSyicu += '<tr class="biaoge1  abnormal" style="background-color:gray">' +
                    '<td class="biaoge1-1 abnormal"><div style="cursor:pointer;"><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.skuCode + '</div></div></div></td>' +
                    '<td class="biaoge1-2 abnormal"><span id="handle_results">' + v.buyerCount + '' + v.unit + '</span></td>' +
                    '<td class="biaoge1-3 abnormal"><span id="create_time">' + v.channelSettledPrice + '元/' + v.unit + '</span></td>' +
                    '<td class="biaoge1-3 abnormal"><span id="create_time">' + v.channelSalePrice + '元/' + v.unit + '</span><br><span style="color: #c62b26">' + ppoi + '</span></td>' +
                    '</tr>';

            })
            // $('.abnormal').children().css('background-color','pink');

    }


    $("#datatable").find("tbody").append($(handStr));
    $("#datatable").find("tbody").append($(hdStrdf));
    $("#datatable").find("tbody").append($(hdStrdfuu));
    $("#datatable").find("tbody").append($(hdSdfuu));
    $("#yicdatatable").find("tbody").append($(hdSyicu));
    refreshStock(1)
    expressNums = result11.data.orderExt.express_num;
    if (results.data.isTpaOrder == 10) {
        serviceDetail();
    }
    //客户代码
    $("input[name='customer_code']").val(results.data.customer_code);
    $("input[name='parent_customer_code']").val(results.data.parent_customer_code);
}

// 服务商详情禁止编辑
function serviceDetail() {
    // 拆单 、操作日志隐藏、刷新-可用库存
    $('.btn').hide();
    // 订单备注编辑隐藏
    $('#isSaveFalse').hide();
    // 商品信息修改结算价表格禁止编辑
    $.each($('.biaoge1-demolitionOrder_3 input'), function(index, item) {
        $(item).attr('disabled', 'disabled')
    });
    $('.serveBtn').hide(); //隐藏服务商按钮

    $('#qualification_documents').prop('disabled', true)
}
/*商品类型鼠标移出事件*/
function producttypeover(id) {
    $("#mouseBox" + id).css({
        display: "inline"
    });
}

function producttypeout(id) {
    $("#mouseBox" + id).css({
        display: "none"
    });
}

/*function isChooes(val) {
    if ($("#final_sent_type1").val()==10){
        //订单类别
        $("#orderCategorys").css({
            display: "inline"
        });
    }else {
        //订单类别
        $("#orderCategorys").css({
            display: "none"
        });
        $("#orderCategory").val("0")


    }
}*/


//物流信息查询
var oddnumber = ''; //配送单号
var orderno = orderId; //订单单号
function logisticsInformation() {
    $("#logisticsInformation").modal("show")
        /*-------------------------物流轨迹-----------------------*/
    oddnumber = ''
    var express_numall = JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.express_num
    if (express_numall != "") {
        var expressNumArr = strReplaceFn(express_numall);
        if (expressNumArr.length > 0) {
            var delivery_numberhtml = '';
            oddnumber = expressNumArr[0];
            $.each(expressNumArr, function(i, item) {
                if (i == 0) {
                    delivery_numberhtml += ' <span class=" delivery_numberactive" oddnumberone="' + item + '" onclick="isclickshow(this)" style="background: rgb(255, 244, 234); border: 1px solid rgb(240, 131, 39); border-radius: 14px; padding: 5px 12px; cursor: pointer; margin-left: 20px;">' + item + '</span>'
                } else {
                    delivery_numberhtml += ' <span class="delivery_number" oddnumberone="' + item + '" onclick="isclickshow(this)" style="background: rgb(247, 247, 247); border: 1px solid rgb(204, 204, 204); border-radius: 14px; padding: 5px 12px; cursor: pointer; margin-left: 20px;">' + item + '</span>'
                }
            })
            $(".delivery_numbercount").html(delivery_numberhtml)
        }
        if (expressNumArr.length > 0) {
            deliveryfn(oddnumber); //页面初始化 调取物流信息 应当传参 配送单号 第一个
        }
    } else {
        $(".logisticsbox").remove();
    }
}

//切换物流信息
function isclickshow(e) {
    oddnumber = $(e).attr('oddnumberone'); //配送单号
    var loadingFlag;
    deliveryfn(oddnumber); // 每次点击 传参相对应的 配送单号
    $(e).css({
        'background': '#FFF4EA',
        'border': '1px solid #F08327',
        'border-radius': '14px',
        'padding': '5px 12px',
        'cursor': 'pointer',
        'margin-left': '20px'
    });
    $(e).siblings().css({
        'background': '#F7F7F7',
        'border': '1px solid #CCCCCC',
        'border-radius': '14px',
        'padding': '5px 12px',
        'cursor': 'pointer',
        'margin-left': '20px',
    });
}

// 物流信息
function deliveryfn(numoddnumber) {
    var formData = new FormData();
    formData.append('orderId', orderId);
    formData.append('expressNum', numoddnumber);
    var deliveryhtml = '';
    $.ajax({
        url: root.dockingplatform.queryLogistics,
        type: "POST",
        data: formData,
        cache: false, // 不缓存数据
        processData: false, // 不处理数据
        contentType: false,
        success: function(data) {
            if (data.data != null) {
                if (data.data.logisticsInfolist == null || data.data.deliverystatus == null) {
                    $(".delivery_companybox").addClass('hide');
                    $(".delivery_exhibitioncont").html('暂无物流信息');
                    $(".verify_info.delivery_detailbox").css('text-align', 'center');
                } else {
                    // if (data.data.status == 0) {
                    $(".delivery_companybox").addClass('show');
                    if (data.errorCode == 0) {
                        deliverystatusfn(data.data.deliverystatus);
                        $(".delivery_company").html(data.data.expName); //配送公司
                        $(".delivery_status").html(statusdate); //快递状态
                        if (data.data.logisticsInfolist.length > 0) {
                            $.each(data.data.logisticsInfolist, function(i, item) {
                                deliveryhtml += '          <div class="delivery_exhibitionbox">\n';
                                if (i != (data.data.logisticsInfolist.length - 1)) {
                                    deliveryhtml += '            <span class="sepcfix_date ">' + item.time + '</span>\n';
                                } else {
                                    deliveryhtml += '            <span class="sepcfix_date sepcfix_datelast">' + item.time + '</span>\n';
                                }
                                deliveryhtml += '            <span class="sepcfix_detailbox">\n';
                                deliveryhtml += '              <p class="sepcfix_img">\n';
                                if (i == 0) {
                                    deliveryhtml += '                <img src="' + srcimgdate + '" class="signforyesimg"  alt="">\n';
                                    if (data.data.logisticsInfolist.length == 1) {
                                        deliveryhtml += ' <span class="vertical_line"></span>\n';
                                    }
                                } else {
                                    if (i != (data.data.logisticsInfolist.length - 1)) {
                                        deliveryhtml += '                <img src="../../../img/signforno_img.png" class="signfornoimg  signfornoimglast"  alt="">\n';
                                    } else {
                                        deliveryhtml += '                <img src="../../../img/signforno_img.png" class="signfornoimg signfornoimgtop"  alt="">\n';
                                    }
                                }
                                if (i != (data.data.logisticsInfolist.length - 1)) {
                                    deliveryhtml += '                <span class="vertical_line"></span>\n';
                                }
                                deliveryhtml += '              </p>\n';
                                deliveryhtml += '            </span>\n';
                                deliveryhtml += '            <span class="sepcfix_luchengbox">\n';
                                if (i == 0) {
                                    deliveryhtml += '<div class="sepcfix_name">' + statusdate + '</div>\n';
                                    deliveryhtml += '              <div class="sepcfix_detail sepcfix_detailtop">' + item.status + '</div>\n';
                                } else {
                                    deliveryhtml += '              <div class="sepcfix_detail sepcfix_detaillast">' + item.status + '</div>\n';
                                }
                                deliveryhtml += '            </span>\n';
                                deliveryhtml += '          </div>';
                            })
                            $(".delivery_exhibitioncont").html(deliveryhtml);
                            $(".verify_info.delivery_detailbox").css('text-align', '');
                            if (data.data.logisticsInfolist.length == 1) {
                                $('span.sepcfix_date.sepcfix_datelast').css('top', '-41px');
                            }
                        }
                    }
                }
                // } else {
                //     if(data.data.status == 0){
                //         $(".delivery_companybox").removeClass('hide');
                //     }else{
                //         $(".delivery_companybox").addClass('hide');
                //     }
                //     $(".delivery_exhibitioncont").html('暂无物流信息');
                //     $(".verify_info.delivery_detailbox").css('text-align', 'center');
                // }
            } else {
                $(".delivery_companybox").addClass('hide');
                $(".delivery_exhibitioncont").html('暂无物流信息');
                $(".verify_info.delivery_detailbox").css('text-align', 'center');
            }
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    });

}

var statusdate = ''; //物流状态 全局变量
var srcimgdate = ''; //图片 全局变量
function deliverystatusfn(status) { /*0：快递收件(揽件)1.在途中 2.正在派件 3.已签收 4.派送失败 5.疑难件 6.退件签收*/
    switch (status) {
        case "0":
            statusdate = "快递收件(揽件)";
            srcimgdate = '../../../img/lanshou-img.png';
            break;
        case "1":
            statusdate = "在途中";
            srcimgdate = "../../../img/signforno_img.png"
        case "2":
            statusdate = "正在派件";
            srcimgdate = "../../../img/peijian-img.png";
            break
        case "3":
            statusdate = "已签收";
            srcimgdate = '../../../img/signforyes_img.png';
            break
        case "4":
            statusdate = "派送失败";
            srcimgdate = "../../../img/signforno_img.png";
            break
        case "5":
            statusdate = "疑难件";
            srcimgdate = "../../../img/signforno_img.png";
            break
        case "6":
            statusdate = "退件签收";
            srcimgdate = "../../../img/signforno_img.png";
            break
    }
}
//关闭
function closelogisticsInformation() {
    $("#logisticsInformation").modal("hide")
}
// 开票信息显隐
function toggleInvoiceInfo() {
    $('.invoice-detail').toggle()
    $('#arrow-up').toggle();
    $('#arrow-down').toggle();
}
// 渲染开票信息
function renderInvoiceInfo(data) {
    var billingMethod = '';
    var invoiceType = '';
    // 0集中开票/1随单开票
    if (data.billingMethod) {
        switch (data.billingMethod) {
            case 1:
                billingMethod = '随单开票';
                break;
            case 2:
                billingMethod = '集中开票';
                break;
            default:
                billingMethod = data.billingMethod;
        }
    } else {
        billingMethod = '';
    }

    if (data.type) {
        switch (data.type) {
            case 1:
                invoiceType = '增值税普通发票';
                break;
            case 2:
                invoiceType = '增值税专用发票';
                break;
            case 3:
                invoiceType = '电子发票';
                break;
            default:
                invoiceType = data.type;
        }
    } else {
        invoiceType = '';
    }
    var invoiceTitleType = ""
    if (data.invoiceTitleType == 1) {
        invoiceTitleType = "个人"
    } else if (data.invoiceTitleType == 2) {
        invoiceTitleType = "单位"
    }

    var invoiceHtml = '<tr>' +
        '<td class="col-3-l"><span class="f-l">开票方式：</span><span>' + billingMethod + '</span></td>' +
        '<td class="col-3-1"><span class="f-l">发票类型：</span><span>' + invoiceType + '</span></td>' +
        '<td class="col-3-1"><span class="f-l">发票抬头：</span><span>' + this.formatTableContent(data.title) + '</span></td>' +
        '</tr>' +
        '<tr>' +
        '<td class="col-3-1"><span class="f-l">纳税人识别号：</span><span>' + this.formatTableContent(data.enterpriseTaxpayer) + '</span></td>' +
        '<td class="col-3-l"><span class="f-l">开户银行：</span><span>' + this.formatTableContent(data.bank) + '</span></td>' +
        '<td class="col-3-1"><span class="f-l">银行账户：</span><span>' + this.formatTableContent(data.account) + '</span></td>' +
        '</tr>' +
        '<tr>' +
        '<td class="col-3-1"><span class="f-l">联系电话：</span><span>' + this.formatTableContent(data.tel) + '</span></td>' +
        '<td class="col-3-1"><span class="f-l">联系地址：</span><span>' + this.formatTableContent(data.address) + '</span></td>' +
        '<td class="col-3-1"><span class="f-l">抬头类型：</span><span>' + invoiceTitleType + '</span></td>' +
        '</tr>' +
        '<tr>' +
        '<td class="col-3-1"><span class="f-l">开票明细：</span><span>' + this.formatTableContent(data.invoiceDetails) + '</span></td>' +
        '<td class="col-3-1"><span class="f-l">收票人姓名：</span><span>' + this.formatTableContent(data.invoiceRecipientName) + '</span></td>' +
        '<td class="col-3-1"><span class="f-l">收票人单位：</span><span>' + this.formatTableContent(data.invoiceRecipientCompany) + '</span></td>' +
        '</tr>' +
        '<tr>' +
        '<td class="col-3-1"><span class="f-l">收票人电话：</span><span>' + this.formatTableContent(data.invoiceRecipientTel) + '</span></td>' +
        '<td class="col-3-1"><span class="f-l">收票人邮箱：</span><span>' + this.formatTableContent(data.invoiceRecipientEmail) + '</span></td>' +
        '<td class="col-3-1"><span class="f-l">收票地址：</span><span>' + this.formatTableContent(data.invoiceRecipientAddress) + '</span></td>' +
        '</tr>';
    $('#invoice-info-table').html(invoiceHtml);
}
// 格式化表格内容
function formatTableContent(ele) {
    if (ele != 0 && !ele) {
        return '';
    }
    return ele;
}
//分单
function reinsurancepolicy() {
    if ($("#orderCategory option:selected").val() == 0) {
        $.Huimodalalert('请编辑订单类别', 2000);
        return false;
    }
    if ($("#warehouseId option:selected").val() == -1) {
        $.Huimodalalert('请编辑发货仓', 2000);
        return false;
    }
    if ($("#secondarysenttype option:selected").val() == -1) {
        $.Huimodalalert('请编辑订单类型', 2000);
        return false;
    }
    if ($("#senttype option:selected").val() == -1) {
        $.Huimodalalert('请编辑配送方式', 2000);
        return false;
    }
    $("#reinsurancepolicys").modal("show")
    var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"))
    var providerall = orderDetail.providers
    var provider = '<option value="">请选择</option><option value="-1">鑫方盛</option>'
    var providerdata = ""
    for (var i = 0; i < providerall.length; i++) {
        providerdata += '<option value="' + providerall[i].providerId + '">' + providerall[i].providerName + '</option>'
    }
    $("#providers").html(provider + providerdata)
}
//确认分配&取消
function confirmallocation(val) {
    if (val == 1) {
        //确认分配
        if ($("#providers option:selected").val() == -1) {
            layer.msg('分配成功', {
                icon: 6,
                time: 1000
            }, function() {
                $("#reinsurancepolicys").modal("hide")
                location.replace(location.href);
            });
        } else {
            $.ajax({
                contentType: "application/json;charset=UTF-8",
                url: root.dockingplatform.distributionTpaOrder,
                cache: false, //禁用缓存
                type: "POST",
                dataType: "json",
                async: false, //优先运行
                data: JSON.stringify({
                    "orderId": orderId,
                    "performingPartyId": $("#providers option:selected").val(),
                    "performingPartyName": $("#providers option:selected").html(),
                    "operateUserId": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                    "operateUserName": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
                }),
                success: function(data) {
                    if (data.errorCode == 0) {
                        layer.msg('分配成功', {
                            icon: 6,
                            time: 1000
                        }, function() {
                            $("#reinsurancepolicys").modal("hide")
                            location.replace(location.href);
                        });
                    } else {
                        $.Huimodalalert(data.msg, 2000);
                    }
                },
            })
        }

    } else if (val == 2) {
        //取消
        $("#reinsurancepolicys").modal("hide")
    }
}
//订单类别修改
function orderCategoryModify() {
    linkage = false
    linkagenum++;
    console.log(linkage)
    console.log(linkagenum)
    if (linkage == false && linkagenum == 2) {
        $.Huimodalalert('请先保存上一次操作', 2000);
        linkagenum = 1
        return false;
    }
    $("#orderCategoryModify").css({
        display: "none"
    });
    $("#orderCategoryCancel").css({
        display: "inline"
    });
    $("#orderCategory").removeAttr("disabled")
}
//订单类别保存取消
function orderCategoryCancel(val) {
    if (val == 1) {
        //保存
        if ($("#orderCategory option:selected").val() == 0) {
            $.Huimodalalert('请选择订单类别', 2000);
            return false
        }
        $.ajax({
            contentType: "application/json;charset=UTF-8",
            url: root.dockingplatform.updateOrderBigTypeByOrderId,
            cache: false, //禁用缓存
            type: "POST",
            dataType: 'json',
            data: JSON.stringify({
                "orderId": orderId,
                "orderBigType": $("#orderCategory option:selected").val(),
                "operateUserId": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                "operateUserName": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,

            }),
            success: function(data) {
                if (data.errorCode == 0) {
                    $.Huimodalalert('编辑成功', 2000);
                    $("#orderCategoryModify").css({
                        display: "inline"
                    });
                    $("#orderCategoryCancel").css({
                        display: "none"
                    });
                    $("#orderCategory").attr("disabled", 'disabled')
                        //发货仓
                    warehouseIdlist()
                        //订单类型
                    secondarysenttypelist()
                        //配送方式
                    senttypelist()

                    linkage = true
                    linkagenum = 0
                    getOrderDetail();
                } else {
                    $.Huimodalalert(data.msg, 2000);
                }

            },
            error: function() {
                $.Huimodalalert('失败！', 2000);
            }
        })
    } else if (val == 2) {
        //取消
        $("#orderCategoryModify").css({
            display: "inline"
        });
        $("#orderCategoryCancel").css({
            display: "none"
        });
        $("#orderCategory").attr("disabled", 'disabled')
        linkage = true
        linkagenum = 0
        getOrderDetail();
    }

}
//获取订单类型
function secondarysenttypelist() {
    var option = ""
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.dockingplatform.listOrderTypeByOrderInfo,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            "orderId": orderId,
            "orderBigType": $("#orderCategory option:selected").val(),
            "warehouseId": $("#warehouseId option:selected").val(),
        }),
        success: function(data) {
            if (data.errorCode == 0) {
                if (data.data != null) {
                    var option2 = '<option value="-1">请选择</option>'
                    for (var i = 0; i < data.data.length; i++) {
                        if ($("#secondarysenttype option:selected").val() != -1) {
                            if ($("#secondarysenttype option:selected").val() == data.data[i].orderTypeId) {
                                option += ' <option value="' + data.data[i].orderTypeId + '" selected>' + data.data[i].orderTypeName + '</option>'

                            } else {
                                option += ' <option value="' + data.data[i].orderTypeId + '" >' + data.data[i].orderTypeName + '</option>'

                            }
                        } else {
                            option += ' <option value="' + data.data[i].orderTypeId + '" >' + data.data[i].orderTypeName + '</option>'
                        }

                    }
                    $("#secondarysenttype").html(option2 + option)
                }

            }
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })
}
//获取订单类型传值
var secondarysenttypeid = ""

function secondarysenttypelist2() {
    var option = ""
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.dockingplatform.listOrderTypeByOrderInfo,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            "orderId": orderId,
            "orderBigType": $("#orderCategory option:selected").val(),
            "warehouseId": $("#warehouseId option:selected").val(),
        }),
        success: function(data) {
            secondarysenttypeid = $("#secondarysenttype option:selected").val()
            if (data.errorCode == 0) {
                if (data.data != null) {
                    for (var i = 0; i < data.data.length; i++) {
                        if ($("#secondarysenttype option:selected").val() != -1) {
                            console.log($("#secondarysenttype option:selected").val())
                            console.log(data.data[i].orderTypeCode)
                            if ($("#secondarysenttype option:selected").val() == data.data[i].orderTypeCode) {
                                secondarysenttypeid = data.data[i].orderTypeId
                            }
                            senttypelist()
                        }

                    }
                }

            }
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })
}
//订单类型修改
function secondarysenttypeModify() {
    linkage = false
    linkagenum++;
    if (linkage == false && linkagenum == 2) {
        $.Huimodalalert('请先保存上一次操作', 2000);
        linkagenum = 1
        return false;
    }
    $("#secondarysenttypeModify").css({
        display: "none"
    });
    $("#secondarysenttypeCancel").css({
        display: "inline"
    });
    $("#secondarysenttype").removeAttr("disabled")
    secondarysenttypelist()
}
//订单类类型存取消
function secondarysenttypeCancel(val) {
    if (val == 1) {
        //保存
        if ($("#secondarysenttype option:selected").val() == -1) {
            $.Huimodalalert('请选择订单类型', 2000);
            return false
        }
        $.ajax({
            contentType: "application/json;charset=UTF-8",
            url: root.dockingplatform.updateOrderTypeByOrderId,
            cache: false, //禁用缓存
            type: "POST",
            dataType: 'json',
            data: JSON.stringify({
                "orderId": orderId,
                "commonOrderType": $("#secondarysenttype option:selected").val(),
                "operateUserId": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                "operateUserName": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,

            }),
            success: function(data) {
                if (data.errorCode == 0) {
                    $.Huimodalalert('编辑成功', 2000);
                    $("#secondarysenttypeModify").css({
                        display: "inline"
                    });
                    $("#secondarysenttypeCancel").css({
                        display: "none"
                    });
                    $("#secondarysenttype").attr("disabled", 'disabled')
                        //发货仓
                    warehouseIdlist()
                        //订单类型
                    secondarysenttypelist()
                        //配送方式
                    senttypelist()
                    linkage = true
                    linkagenum = 0
                    getOrderDetail();
                } else {
                    $.Huimodalalert(data.msg, 2000);
                }

            },
            error: function() {
                $.Huimodalalert('失败！', 2000);
            }
        })
    } else if (val == 2) {
        //取消
        $("#secondarysenttypeModify").css({
            display: "inline"
        });
        $("#secondarysenttypeCancel").css({
            display: "none"
        });
        $("#secondarysenttype").attr("disabled", 'disabled')
        linkage = true
        linkagenum = 0
        getOrderDetail();
    }

}
//获取发货仓
function warehouseIdlist() {
    var option = ""
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.dockingplatform.listWarehouseByOrderBigType,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            "orderId": orderId,
            "orderBigType": $("#orderCategory option:selected").val(),
        }),
        success: function(data) {
            if (data.errorCode == 0) {
                if (data.data != null) {
                    var option2 = '<option value="-1">请选择</option>'
                    for (var i = 0; i < data.data.length; i++) {
                        if ($("#warehouseId option:selected").val() != -1) {
                            if ($("#warehouseId option:selected").val() == data.data[i].warehouseId) {
                                option += ' <option value="' + data.data[i].warehouseId + '" selected>' + data.data[i].warehouseName + '</option>'

                            } else {
                                option += ' <option value="' + data.data[i].warehouseId + '" >' + data.data[i].warehouseName + '</option>'

                            }
                        } else {
                            option += ' <option value="' + data.data[i].warehouseId + '" >' + data.data[i].warehouseName + '</option>'
                        }

                    }
                    $("#warehouseId").html(option2 + option)
                }
            }
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })
}
//发货仓修改
function warehouseIdModify() {
    linkage = false
    linkagenum++;
    if (linkage == false && linkagenum == 2) {
        $.Huimodalalert('请先保存上一次操作', 2000);
        linkagenum = 1
        return false;
    }
    $("#warehouseIdModify").css({
        display: "none"
    });
    $("#warehouseIdCancel").css({
        display: "inline"
    });
    $("#warehouseId").removeAttr("disabled")
    warehouseIdlist()
}
//发货仓保存取消
function warehouseIdCancel(val) {
    if (val == 1) {
        //保存
        if ($("#warehouseId option:selected").val() == -1) {
            $.Huimodalalert('请选择发货仓', 2000);
            return false
        }
        $.ajax({
            contentType: "application/json;charset=UTF-8",
            url: root.dockingplatform.updateWarehouseByOrderId,
            cache: false, //禁用缓存
            type: "POST",
            dataType: 'json',
            data: JSON.stringify({
                "orderId": orderId,
                "warehouseId": $("#warehouseId option:selected").val(),
                "operateUserId": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                "operateUserName": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,

            }),
            success: function(data) {
                if (data.errorCode == 0) {
                    $.Huimodalalert('编辑成功', 2000);
                    $("#warehouseIdModify").css({
                        display: "inline"
                    });
                    $("#warehouseIdCancel").css({
                        display: "none"
                    });
                    $("#warehouseId").attr("disabled", 'disabled')
                        //发货仓
                    warehouseIdlist()
                        //订单类型
                    secondarysenttypelist()
                        //配送方式
                    senttypelist()
                    linkage = true
                    linkagenum = 0
                    getOrderDetail();
                } else {
                    $.Huimodalalert(data.msg, 2000);
                }

            },
            error: function() {
                $.Huimodalalert('失败！', 2000);
            }
        })
    } else if (val == 2) {
        //取消
        $("#warehouseIdModify").css({
            display: "inline"
        });
        $("#warehouseIdCancel").css({
            display: "none"
        });
        $("#warehouseId").attr("disabled", 'disabled')
        linkage = true
        linkagenum = 0
        getOrderDetail();
    }

}
//获取发配送方式
function senttypelist() {
    var option = ""
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.dockingplatform.listSentTypeByOrderInfo,
        cache: false, //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            "orderTypeId": secondarysenttypeid,
            "warehouseId": $("#warehouseId option:selected").val(),
        }),
        success: function(data) {
            if (data.errorCode == 0) {
                if (data.data != null) {
                    var option2 = '<option value="-1">请选择</option>'
                    for (var i = 0; i < data.data.length; i++) {
                        if ($("#senttype option:selected").val() != -1) {
                            if ($("#senttype option:selected").val() == data.data[i].sentTypeCode) {
                                option += ' <option value="' + data.data[i].sentTypeCode + '" selected>' + data.data[i].sentTypeName + '</option>'

                            } else {
                                option += ' <option value="' + data.data[i].sentTypeCode + '" >' + data.data[i].sentTypeName + '</option>'

                            }
                        } else {
                            option += ' <option value="' + data.data[i].sentTypeCode + '" >' + data.data[i].sentTypeName + '</option>'
                        }

                    }
                    $("#senttype").html(option2 + option)
                }
            }
        },
        error: function() {
            $.Huimodalalert('失败！', 2000);
        }
    })
}
//配送方式修改
function senttypeModify() {
    linkage = false
    linkagenum++;
    if (linkage == false && linkagenum == 2) {
        $.Huimodalalert('请先保存上一次操作', 2000);
        linkagenum = 1
        return false;
    }
    $("#senttypeModify").css({
        display: "none"
    });
    $("#senttypeCancel").css({
        display: "inline"
    });
    $("#senttype").removeAttr("disabled")
    secondarysenttypelist2()
}
//配送方式保存取消
function senttypeCancel(val) {
    if (val == 1) {
        //保存
        if ($("#senttype option:selected").val() == -1) {
            $.Huimodalalert('请选择配送方式', 2000);
            return false
        }
        $.ajax({
            contentType: "application/json;charset=UTF-8",
            url: root.dockingplatform.updateSentTypeByOrderId,
            cache: false, //禁用缓存
            type: "POST",
            dataType: 'json',
            data: JSON.stringify({
                "orderId": orderId,
                "sentType": $("#senttype option:selected").val(),
                "operateUserId": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                "operateUserName": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,

            }),
            success: function(data) {
                if (data.errorCode == 0) {
                    $.Huimodalalert('编辑成功', 2000);
                    $("#senttypeModify").css({
                        display: "inline"
                    });
                    $("#senttypeCancel").css({
                        display: "none"
                    });
                    $("#senttype").attr("disabled", 'disabled')
                        //发货仓
                    warehouseIdlist()
                        //订单类型
                    secondarysenttypelist()
                        //配送方式
                    senttypelist()
                    linkage = true
                    linkagenum = 0
                    getOrderDetail();
                } else {
                    $.Huimodalalert(data.msg, 2000);
                }

            },
            error: function() {
                $.Huimodalalert('失败！', 2000);
            }
        })
    } else if (val == 2) {
        //取消
        $("#senttypeModify").css({
            display: "inline"
        });
        $("#senttypeCancel").css({
            display: "none"
        });
        $("#senttype").attr("disabled", 'disabled')
        linkage = true
        linkagenum = 0
        getOrderDetail();
    }

}

//检查是否满足货到付款
function check_Meet_Pay() {
    var customer_code = $("input[name='customer_code']").val();
    var parent_customer_code = $("input[name='parent_customer_code']").val();
    var money_type = $("#money-type").html();

    if (money_type != "货到付款" || parent_customer_code != "D000000058") {
        pass();
    } else {
        $.ajax({
            url: root.dockingplatform.queryIsAllowCashDelivery,
            cache: false, //禁用缓存
            type: "POST",
            dataType: 'json',
            data: { customerCode: customer_code },
            success: function(result) {
                layer.open({
                    type: 1,
                    title: "提示",
                    offset: "auto",
                    content: "<div style='margin: 20px;'>该用户不满足货到付款需求，可能因为有欠款，请联系相关人员咨询。”确认则提交成功，取消则返回上一级界面</div>",
                    area: "620px",
                    btn: ["确认", "取消"],
                    btnAlign: "c",
                    yes: function() {
                        layer.close(layer.index);
                        pass();
                    },
                    cancel: function() {
                        //alert("取消");
                    },
                });
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest);
            }
        });
    }
}